单元测试用例生成单元测试

2023-09-03 00:06:25 作者:人最怕就是动了情

有没有人尝试过​​的单元测试发电机净?

Has anybody tried any Unit Test generators for .Net?

我认为虽然不会有任何替代任何好的单元测试写谁写的功能的人,但我认为这会带走一些工作,是一个起点上,我们可以更好的单元试验。

I assume although it won't be any substitute for any good unit test written by a person who has written the functionality, but I think it will take away some of work and be a starting point on which we can better the unit tests.

感谢。

推荐答案

单元测试生成是一种错误的方式来进行单元测试。正确的方法做单元测试是你写的功能code之前创建测试用例,然后制定code,直到测试验证,这是知道的TDD(测试驱动开发)。

Unit test generation is the wrong way to perform unit testing. The proper way to do unit testing is to create test cases before you write functional code, then develop your code until the tests validate, this is know as TDD (Test Driven Development).

其中一个关键原因单元测试生成的是一个坏主意,因为如果在现有的code任何错误,该测试将针对这些漏洞产生的,因此,如果您修复他们的未来,坏测试将失败,你会认为事情是坏了,当它真正得到解决。

One of the key reasons unit test generation is a bad idea is because if there are any bugs in your existing code, the tests will be generated against those bugs, therefore if you fix them in the future, the bad tests will fail and you'll assume something is broken, when it's actually been fixed.

不过,由于code被写入,它现在桥下的水。而可能的马车单元测试是比没有单元测试要好。我一直preferred NUnit的,有一个NUnit的兼容测试发生器这里(很实惠)。

But since the code is written, it's now water under the bridge. And possible buggy unit tests are better than no unit tests at all. I've always preferred NUnit and there's a NUnit compatible test generator here (very affordable).