How to NOT write unit tests:

A colleague of mine has developed a new package of software, many of our new projects are going to use. So in his presentation of the new functionalities he also showed us that he used unit tests to cover some of his code. So i asked him to show me that all tests passes.

He: I can show you, but one test suit will fail currently.

Me: Why?? You told us, everything is finished and works fine.

He: That's right, but they will fail because I'm currently not in the customer VPN.

Me: Excuse me, WHAT??

He: Yes, I'm not in the VPN that connects me to this one customers facility in Hungary, where the counterpart of the software is runnung live.


He: Yes, so I can check, that the telegramms I send are right. If I get back the right acknowledgement, the telegramm structure is right and my code is working.

Me: You know, that is not the porpose of unit tests? You know, that these test should run in any environment?

He: But they are proving, that my code is working. Everytime I change something I connect to the customer and let the tests run.

Me: ...

Despite the help of some other developers we could not convince him that this was not good and he should remove them. So now this package is used in 2 new projects and this test suit is still failing, everytime you execute all unit tests.

  • 8
    And that's why beginners shouldn't have solo projects at work.

    I mean, it's funny in a way. He's equating unit tests with any sort of automated tests. And went surprisingly far with that misconception. 🤦‍♂️ #murphyslaw
  • 7
    If it makes a network call, it's no longer a unittest
  • 0
    it’s an integration test not a unit test, nothing wrong with them when they are treated as such and run after the unit tests in a ci environment
  • 0
    Isn't where where we use mockedup everything?
  • 0
    This is the real "porpoise of unit tests:"
  • 0
    Do it like me. A solo developer who do not use unit test. I use other co workers to test the site.
  • 0
    What an absolute *unit*! Haha right? Right guys? Guys...?
Your Job Suck?
Get a Better Job
Add Comment