Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# TFS生成中的System.AppDomainUnloadedException会延迟整个测试运行_C#_Unit Testing_Tfs_Tfsbuild - Fatal编程技术网

C# TFS生成中的System.AppDomainUnloadedException会延迟整个测试运行

C# TFS生成中的System.AppDomainUnloadedException会延迟整个测试运行,c#,unit-testing,tfs,tfsbuild,C#,Unit Testing,Tfs,Tfsbuild,我们看到基于TFS的构建花费了太长时间,并调查了原因。然后我发现,在测试运行期间的每个构建中,一些测试在最后一次测试结束后30秒后开始。所以每次构建都会浪费很多时间!暂停发生时的模式是非常随机的。当我在构建中深入查看活动日志时,我注意到在这些中断处有这样一条消息: System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started

我们看到基于TFS的构建花费了太长时间,并调查了原因。然后我发现,在测试运行期间的每个构建中,一些测试在最后一次测试结束后30秒后开始。所以每次构建都会浪费很多时间!暂停发生时的模式是非常随机的。当我在构建中深入查看活动日志时,我注意到在这些中断处有这样一条消息:

System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.

这是什么意思?是否有办法检查哪个测试存在此问题以及如何避免此问题?谢谢。

这通常发生在做异步工作的测试上。@jessehouwing你是说测试不做异步工作吗?这似乎不是一个非常实际的解决方案。。。值得一提的是,我在我的TFS构建中也遇到过这种情况,这几乎意味着如果构建结果有时因为这个原因而失败,而不是因为逻辑不正确,我就不能相信它们。我的意思是,您的异步代码可能会在生产中导致同样的问题,因此您需要修复它。设置线程id可能会有帮助,以便您可以将其追溯到测试……这通常发生在执行异步工作的测试上。@jessehouwing您是否建议测试不执行异步工作?这似乎不是一个非常实际的解决方案。。。值得一提的是,我在我的TFS构建中也遇到过这种情况,这几乎意味着如果构建结果有时因为这个原因而失败,而不是因为逻辑不正确,我就不能相信它们。我的意思是,您的异步代码可能会在生产中导致同样的问题,所以你需要修复它。它可能有助于设置线程id,以便你可以追溯到测试。。。