自动生成单元测试用例的.NET和Java [英] Automatic generation of Unit test cases for .NET and Java

查看:545
本文介绍了自动生成单元测试用例的.NET和Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有好的工具来生成给说.NET或Java项目,它生成单元测试用例,将覆盖几乎100%code覆盖单元测试用例。测试用例的数量可能是成正比的code其中越高圈复杂度,更大的生成测试用例集(循环和条件越高,圈复杂度较高的嵌套)圈复杂度。我没想到它是全功能的(比如我要建立的单元测试和运行其生成之后),但我要说的是,它可以在测试案例的模板风格的你在哪里修改适合你的预期需求的情况。但它也应该有一个正确的安装和拆卸方法是不够好,以检测是否为单元测试的模拟对象应使用应该有任何相关性。那么,有没有存在这样的工具?

Is there a good tool to generate unit test cases given say a .NET or Java project, it generates unit test cases that would cover an almost 100% code coverage. The number of test cases could be directly proportional to the cyclomatic complexity of the code (the higher the nesting of loops and conditions the higher the cyclomatic complexity) where the higher the cyclomatic complexity, the greater the set of test cases are generated. I'm not expecting it to be fully functional (say I'm going to build the unit tests and run it after its been generated), but I would say that it can have a template style in the test case where you are to modify the case that suits your intended needs. But it should also have a proper setup and teardown method and is good enough to detect if mock objects for unit testing should be used should there be any dependencies. So, is there such a tool that exists?

推荐答案

对于.NET,微软 Pex公司< /一>这将有望成为主流的.NET 4.0,以及 code合同的。我强烈推荐观看的频道9视频。

For .NET, Microsoft has Pex which will hopefully go mainstream for .NET 4.0, along with Code Contracts. I highly recommend watching the Channel 9 video.

这让我感到这样的事情是非常好非常数据驱动类 - 解析器等,我看不到,我会很经常的开始的使用,但一个有用的工具在你的军械库不过。

It strikes me that this sort of thing is very good for very data-driven classes - parsers etc. I can't see that I'd very often start off with it, but a useful tool to have in your armoury nonetheless.

这篇关于自动生成单元测试用例的.NET和Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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