简体   繁体   English

运行Visual Studio单元测试与运行ReSharper单元测试,差异?

[英]Run Visual Studio Unit Tests vs Run ReSharper Unit Tests, differences?

So I have been running into all kinds of interesting problems in VisualStudio 2008 when running Unit Tests. 因此,在运行单元测试时,我在VisualStudio 2008中遇到了各种有趣的问题。

Such as, when running Visual Studio Unit Tests some tests are failing together but passing individually. 例如,在运行Visual Studio单元测试时,某些测试会一起失败,但会单独传递。 This is happening because some class level variables in that test class is being reused in the Unit Tests. 发生这种情况是因为该测试类中的某些类级变量正在单元测试中重用。

Now normally I would go into each class and fix this problem manually! 现在通常我会进入每个班级并手动修复此问题! However, we are talking about tests that range in the thousands! 但是,我们正在讨论的测试数量达到数千个!

Now here comes the interesting dilemma, using both ReSharper Unit Tests and TFS BuildServer they are passing together! 现在有了一个有趣的困境,使用ReSharper单元测试和TFS BuildServer一起传递!

Is there any way that I could configure the VS Unit Test Solution to run in the same fashion? 有没有什么方法可以配置VS单元测试解决方案以相同的方式运行? I want to avoid calling the [TestInitialize] methods in the [TestCleanup] methods. 我想避免在[TestCleanup]方法中调用[TestInitialize]方法。

This is usually a byproduct of differently ordered tests. 这通常是不同排序测试的副产品。 ReSharper 4.x and earlier runs unit tests based on the order they appear in the source file. ReSharper 4.x及更早版本根据它们在源文件中出现的顺序运行单元测试。 Almost all other unit test runners run tests in alphabetical order. 几乎所有其他单元测试运行器都按字母顺序运行测试。 This different ordering can (but never should) affect whether or not tests pass/fail (based on left over data in a database or statics). 这种不同的排序可以(但绝不应该)影响测试是否通过(基于数据库中的剩余数据或静态)。

ReSharper 5.0 is not using a custom runner anymore so it should fix these inconsistencies. ReSharper 5.0不再使用自定义运行器,因此它应该修复这些不一致性。

However, this type of inconsistency indicates a problem in the tests. 但是,这种不一致表明测试中存在问题。 Some are leaving data behind that they should be cleaning up and some are dependent on, or hurt by, data left over from a previous test. 有些人留下了数据,他们应该清理,有些人依赖于先前测试留下的数据,或者受到以前测试遗留的数据的影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio 2012 / Resharper单元测试不运行 - Visual Studio 2012 / Resharper Unit Tests don't run 在 Visual Studio/Resharper 中以调试模式运行单元测试时出现“不确定:测试未运行”错误 - “Inconclusive: Test not run” error running unit tests in debug mode in Visual Studio / Resharper 在Visual Studio 2012中两次运行某些单元测试 - Run some unit tests twice in Visual Studio 2012 Visual Studio 2010 是否只运行 4.0 单元测试? - Will Visual Studio 2010 only run 4.0 unit tests? Visual Studio单元测试:在每次测试之前运行初始化代码 - Visual Studio Unit tests: run initialization code before each test Visual Studio不会在测试类中运行所有单元测试 - Visual Studio does not run all the unit tests in a test class 在Visual Studio中运行应用程序时如何运行单元测试 - How to run unit tests when running the application in visual studio 单元测试在Visual Studio中“全部运行”但单独传递时失败 - Unit Tests Fail when “Run All” in Visual Studio but passes individually Visual Studio 2015中的单元测试不会运行 - Unit Tests in Visual Studio 2015 don't run 在 Visual Studio 2013 中运行单元测试时运行其他项目 - Run other project when running unit tests in Visual Studio 2013
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM