News for hackers. Stuff that matters.
Re:Evil Unit Testing (2019) by JoeNr76 on Thursday September 24, 2020 @09:55AM (#24578614)
"The smallest amount of testable code. Often a single method/function,"

I hate (HAAAAATE) that definition of unit test. That's how some IDEs implemented unit tests, but it's not what was originally meant with the term 'unit'

The unit tests the author means has no value outside testing while you are programming the code. For real value, unit tests shouldn't be bound to the implementation of your code.

Unit tests should test a "unit of functionality", not a technical part of the code.

Re:Evil Unit Testing (2019) by WolfOliver on Thursday September 24, 2020 @10:13AM (#24578783)
actually the origin of the term unit test means a test can be executed as a unit, it does not has dependencies to other tests. It had nothing to do with testing code in isolation.
Re:Evil Unit Testing (2019) by nerdponx on Thursday September 24, 2020 @10:07AM (#24578720)
That's why they said "often".

A better definition might be "the smallest amount of testable functionality".

Re:Evil Unit Testing (2019) by exdsq on Thursday September 24, 2020 @10:28AM (#24578905)
Which is a function.
Re:Evil Unit Testing (2019) by JoeNr76 on Thursday September 24, 2020 @03:42PM (#24582688)
It might start out as a function, then become a factory, then an object and if you bind your test to the implementation details of this code, you will have to rewrite your test every time you refactor your code. Not ideal.