Writing standards for unit testing

前端 未结 10 948
自闭症患者
自闭症患者 2021-01-31 12:05

I plan to introduce a set of standards for writing unit tests into my team. But what to include?

These two posts (Unit test naming best practices and Best practices for

10条回答
  •  花落未央
    2021-01-31 12:56

    1. Try to use as few assert statements per test method as possible. This makes sure that the purpose of the test is well-defined.
    2. I know this will be controversial, but don't test the compiler - time spent testing Java Bean accessors and mutators is better spent writing other tests.
    3. Try, where possible, to use TDD instead of writing your tests after your code.

提交回复
热议问题