Should I write unit test for everything?

前端 未结 13 1489
太阳男子
太阳男子 2020-12-30 00:36

I am wondering should I write unit test for everything. There are some classes is very difficult to write unit test. For example, I am writing some program for handling audi

13条回答
  •  温柔的废话
    2020-12-30 01:14

    Code that capture and replay audio cannot be unit-tested (albeit you could test that the capture method returns an error when called when the class isn't successfully bound to a resource).

    However, unless you simply write the captured sound to disk the code that invokes your capture and play classes certainly can.

    Two pieces of advice:

    • Don't test the compiler (e.g. getter and setter)
    • Test everything that could possibly break

提交回复
热议问题