Least worth the unit test you've ever written?

On the SO blog and podcast, Joel and Jeff discussed the often-overlooked moments when unit testing a particular function is simply not worth the effort. Those times when unit testing a simple function is so complex, unpredictable, or impractical that the cost of the test does not reflect the value of the function. In the case of Joel, in this example, for a complex comparison of images, the quality of compression was simply determined if they decided to write a test.

In what cases did you encounter a situation? Common areas that I can think of are graphical interfaces, page layout, audio testing (testing so that, for example, an audio warning), etc.

I am looking for horrible stories and real real examples, not speculations (for example, I just did). Bonus points, if you or someone who was supposed to write this "impossible" test went ahead and wrote down anyway.

+3
source share
5 answers
@Test
public void testSetName() {
    UnderTest u = new UnderTest();
    u.setName("Hans");
    assertEquals("Hans", u.getName());
}

Testing the set / get methods is just stupid, you don't need it. If you have to do this, your architecture has some serious flaws.

+11
source
Foo foo = new Foo();
Assert.IsNotNull(foo);
+8
source

. , , , .

, , , (.. -). , , .

, ?

+2

, unit test - , , . ( ( - )), unit test , , , "".

"" , "get/set Name". -, , , .

unit test , , , , unit test.

+1
source

As soon as I wrote a unit test to throw a concurrency error, in response to a call in the C2 Wiki .

This turned out to be unreasonably difficult and hinted that it would be better to process parallel code to ensure that it is correct on a more fundamental level.

0
source

Source: https://habr.com/ru/post/1702798/


All Articles