简体   繁体   English

Visual Studio 2015中的测试执行错误(2013年工作)

[英]Test execution error in Visual Studio 2015 (worked in 2013)

We are in the process of upgrading from Visual Studio 2013 Update 5 to Visual Studio 2015 Update 1. 我们正在从Visual Studio 2013 Update 5升级到Visual Studio 2015 Update 1的过程中。

Our Solution has many tests and we use NUnit 2.6.4, along with the NUnit Test Adapter for NUnit 2.x. 我们的解决方案有很多测试,我们使用NUnit 2.6.4以及用于NUnit 2.x的NUnit测试适配器。

When running these tests in Visual Studio 2013, they all run perfectly well. 在Visual Studio 2013中运行这些测试时,它们都运行良好。

However, when running in Visual Studio 2015 the first 200 odd tests run, then execution stops. 但是,在Visual Studio 2015中运行时,先运行前200个奇数测试,然后执行停止。 I can then select the tests that have not yet run and successfully execute these. 然后,我可以选择尚未运行的测试并成功执行这些测试。 I have the latest ReSharper installed in both VS2013 and VS2015 and it happily executes all the tests. 我在VS2013和VS2015中都安装了最新的ReSharper,它愉快地执行了所有测试。

We've been keeping test-coverage details for each release since the dawn of time, and from Visual Studio's test runner it shows me the number of blocks covered. 自从黎明以来,我们就一直保留每个版本的测试覆盖率详细信息,并且从Visual Studio的测试运行器中可以看到我所覆盖的块数。 But ReSharper shows us the number of statements covered. 但是ReSharper向我们显示了所涵盖的语句数量。 Slightly different values, but they'd mess up our charts. 值略有不同,但它们会使我们的图表混乱。

When test execution fails, it creates a Dump file (it also creates some XML files that just seem to show what DLLs I've installed). 当测试执行失败时,它会创建一个转储文件(它还会创建一些XML文件,这些文件似乎只是显示我已安装的DLL)。 I can open this and "debug" it, but it simply shows me a line of code that fails, and the call stack shows only [Managed Code], which means I can't identify the actual test that's causing the issue. 我可以打开它并对其进行“调试”,但是它只是向我显示了一行失败的代码,并且调用堆栈仅显示了“托管代码”,这意味着我无法确定导致该问题的实际测试。

The fact that this works perfectly in VS2013 and in ReSharper running in VS2015 suggests that "it's not our fault", but whilst I'd like to think that, it doesn't help me fix this. 这在VS2013和在VS2015中运行的ReSharper中完美运行的事实表明“这不是我们的错”,但是尽管我想这样想,但这无济于事。

Any ideas? 有任何想法吗?

Thanks 谢谢

Griff 格里夫

Tracked down the problem. 找出问题所在。 We had one class in our Solution that implements IDispose and one of our Unit tests didn't dispose of that class, it just allowed it to go out of scope. 我们的解决方案中有一个实现IDispose的类,而我们的单元测试之一没有处理该类,只是允许它超出范围。

So because the Disposable object hadn't been disposed, the class' Finalizer hadn't been suppressed. 因此,由于尚未处理Disposable对象,因此未抑制类的Finalizer。 The GC therefore called the Finalizer which in turn attempted to access another object that had also gone out of scope, resulting in an exception that crashed the Test Execution Runner. 因此,GC调用了终结器,该终结器又试图访问也超出范围的另一个对象,从而导致使测试执行运行程序崩溃的异常。

Interesting that VS2015 running NUnit 2.x crashes, but the identical setup in VS2013 copes fine. 有趣的是,运行NUnit 2.x的VS2015崩溃了,但是VS2013中的相同设置可以很好地应对。

As an aside, when debugging the DUMP file (see above), I realized that the call stack was irrelevant, I just had to put in some defensive coding in the Finalizer. 顺便说一句,调试DUMP文件时(见上文),我意识到调用堆栈是无关紧要的,我只需要在终结器中放入一些防御性代码即可。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM