-
Notifications
You must be signed in to change notification settings - Fork 5k
[Improvement] unit test suggestion #3700
Copy link
Copy link
Closed
Description
Describe the question
- Put multi unit test cases in one method
- Only verify whether the result is successful or fail, not verify the data after successful
What are the current deficiencies and the benefits of improvement
- Put one unit test case in one method, take unit test case as the minimum test unit. Otherwise, the assertion failure of the previous unit test case will cause the subsequent unit test case to not be executed. If you just want to classify unit test cases, you can use the internal classes of junit5 and @DisplayName.
- Focus on verifying data. Focus on verifying data. If you just verify the success or failure, it will be meaningless. It looks like blindly increasing coverage. Such unit test will tolerate errors.
Describe the question
- 将多单元测试用例放在一种方法中
- 只验证结果成功还是失败, 不验证成功后的数据
What are the current deficiencies and the benefits of improvement
- 将一个单元测试用例放在一个方法中, 以单元测试用例为最小单元. 否则前一个单元测试用例的断言失败会导致后面的单元测试用例不会被执行. 如果只是想对单元测试用例分类, 可以使用junit5 的内部类和@DisplayName.
- 侧重验证数据. 如果只是验证成功与否, 这样意义不大. 看起来像是盲目提高覆盖率. 这样的单元测试用会容忍错误.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels