Should one create unit tests involving IO? Ie, testing a class method for serializing/deserializing another object开发者_运维问答?
Yes - When you are writing unit tests for the code that does the IO.
No - When you are writing unit tests for code that call the methods that you just tested above.
I'd mark the first set of tests with a xUnit category/tag marked 'Slow' or some such label and run them less frequently. Over time they will significantly slow down the time needed to run your automated test suite. So make it easy to exclude the slow tests, => developer feedback stays close to instantaneous and have the build server run the slow tests along with the rest on every check-in. If it's really time consuming.. then maybe you can run the "Slow" tests every night or so.
精彩评论