C# + NUnit - Unit testing methods working on long binary arguments
I would like to write unit tests for some classes with methods having byte
array arguments. There are about 100 methods in total, and the array size
ranges from 5-10 to a few 100 bytes. How should I generate and store the
test arrays?
Should I generate them manually or by some generator code (which should be
unit tested, too)?
Should I generate them in memory during the test, or should I generate
them in advance and store them somewhere?
In the latter case, should I store them in files (even if unit tests
shouldn't touch the file system), or should I store them inside the test
code itself (for example, in strings in hexadecimal format, like this: "47
08 00 14 etc.")?
I started to create them manually and store them in the test code in hex
strings. I worked a lot with such binary strings, so I can read them
relatively easily ("I don't even see the code. All I see is blonde,
brunette, redhead.") The problem is, this approach is slow, and I think
using an automatic generator would result in more maintainable tests. But
how should I test that the output of the generator is correct? Sounds like
Catch-22...
No comments:
Post a Comment