Friday, November 6, 2020

Government's big announcement regarding unit test


Government's big announcement regarding unit test

 What is a unit test?  I understand that essentially you are trying to isolate atomic functionality but how do you test for it?  When is it necessary?  When is this funny?  Can you give an example?  (Preferably in C? I mostly hear about this from Java devs on this site, so maybe it's specific to object-oriented languages? I don't really know.)

 I know that many programmers swear religiously by unit testing.  What is this all about?

Make sure you test the code you write.  What technique do you use?  For example, you can sit in a debugger and step through the code and see what happens.  You can execute code against any given test data.  You can create special inputs because you know that your code has some interesting behavior for certain input values.  Suppose your content uses someone else's content and it is not ready yet, then you duplicate your code so that your code has at least some fake answers.

 In all cases you can do some degree unit tests.  The last one is interesting - you are testing too much in isolation, testing your UNIT, even if they are not ready yet.

(1) Tests that can be easily reused are very useful - there is no end to late creep defects.  The opposite test sitting in a debugger is mind-numbing.

 2).  When you write your code, or the activity of creating interesting tests before you write your code, you get to focus on your fringe cases.  Those annoying zero and zero inputs, they "shut down with an error".  I'm getting better code as a result of good unit testing.

 3).  There is a cost to maintain the test.  Generally it is worth it, but do not underestimate the efforrt of working them.

 4).  There may be a tendency to over-emphasize unit tests.  Really interesting bugs creep when the pieces are integrated.  You replace the library you mocked with the real thing and lo!  It doesn't quite do what they said on the tin.  There is still a role for manual or exploit testing. The insightful human tester receives special faults.  From the point

No comments:

Post a Comment