如何保证junit测试的质量? [英] How to ensure quality of junit tests?

查看:94
本文介绍了如何保证junit测试的质量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有验证JUnit测试或集成测试质量的可靠方法?

Are there proven ways of verifying quality of junit tests or integration tests?

您的业务分析师是否应该对单元测试进行审查以确保准确性?还是还有其他方法? 在传统的代码优先"环境中,同行或领导者将审核测试计划,但是自动化测试又如何呢?

Should your business analyst review unit tests to cerfity? Or are there any other ways? In the traditional code first environment a peer or lead would review the test plan but how about automated tests?

我查看了此stackflow 线程,但无法提取任何有意义的东西.

I looked at this stackflow thread but couldn't extract anything meaningful stuff.

有想法吗?

推荐答案

突变测试 代码覆盖率可以验证测试的质量.

因此,首先检查您的代码覆盖率是否足够高.在通过突变测试验证之后,您的测试很好.变异测试工具会在生产代码中进行少量更改,然后重新运行测试-修改后,好的测试应该会失败.对于Java中的突变测试工具,请查看 PIT突变测试和此博客文章:

So first check than your code coverage is high enough. After this verify with mutation testing than your test are good. Mutation testing tool makes small change(s) in production code and reruns test - after a modification a good test should fail. For mutation testing tool in Java look at PIT Mutation Testing and this blog post: Introduction to mutation testing with PIT and TestNG

但这还不够,测试应该写得很好并且可读性.因此,您还需要代码审查和测试的质量规则验证.我推荐一本关于编写好的测试的好书,实用单元测试.第10章:可维护的测试是免费的.

But this is still not enough, tests should be good written and readable. So you need code review also and quality rules verification for tests. I recommend nice book about writing good tests Practical Unit Testing. Chapter 10: Maintainable tests from this book is available for free.

这篇关于如何保证junit测试的质量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆