11
LMagnus
6y

Just found a unit test in a legacy project that is over 300 lines long, creates files on the server and multiple records in the database, then deletes them all. It takes over two minutes to run.

Madness

Comments
  • 1
    This isn't madness,

    THIS...IS...HILARIOUS...wait I mean SPARTA
  • 0
    *shrug* Sometimes, legacy systems are so brittle you have to hack it to get unit tests working.
  • 0
    @Jantho1990 even if that's the case adding poor decisions to poor decisions is not the way forward.
  • 0
    @LynxMagnus The "proper" way forward for legacy systems that are so brittle is to rebuild them so they no longer become brittle. That much is obvious. But, depending on how poorly the code is written and how garishly it is architected, that can take months, maybe years of dedicated work. Good luck selling that to the folks upstairs.

    "Is this really necessary?"

    "Yes, right now it's a miracle anything even works!"

    "Well, do it in your spare time, then! Meanwhile, here's this great new idea you need to implement..."

    Given the choice between imperfect unit tests and no unit tests...at least imperfect unit tests still provide info, and I'll take that over waiting for the whole system to be refactored so we can make proper unit tests with mocks and spies and everything.
  • 0
    The unit tests were written the same time the project was created. That should have been a hint to the developers that there were issues with what they were doing and stopped to rethink.
Add Comment