简体   繁体   English

从TeamCity运行NUnit测试时出现FileNotFoundException

[英]FileNotFoundException when running NUnit tests from TeamCity

I am using the built in TeamCity NUnit runner to run tests stored in .DLL files. 我使用内置的TeamCity NUnit运行程序来运行存储在.DLL文件中的测试。

My .DLLs are referencing other DLLs which are present in the same folder. 我的.DLL正在引用同一文件夹中存在的其他DLL。

When running these, i am getting a FileNotFoundException for the referenced DLLs. 运行这些时,我得到引用的DLL的FileNotFoundException。

How can i fix this? 我怎样才能解决这个问题? I am thinking perhaps the TC NUnit runner is using some other dir as the main app execution folder, and thus preventing from files that are actually residing next to the test DLL to not load properly, but cannot prove this claim yet... 我想也许TC NUnit跑步者正在使用其他一些目录作为主应用执行文件夹,从而防止实际驻留在测试DLL旁边的文件无法正确加载,但无法证明这一说法......

Anyone else encountered this behaviour? 其他人遇到过这种行为?

OK the problem is solved and it is indeed silly and embarrassing: 好的问题解决了,确实很愚蠢和令人尴尬:

I have set the NUnit test runner to execute these tests: 我已经设置了NUnit测试运行器来执行这些测试:

**/*.Tests.dll

This means that it will include tests from /bin/Debug/ and also from other folders, such as obj/ 这意味着它将包括/bin/Debug/以及其他文件夹中的测试,例如obj/

In these folders, no references are included of course, making the same tests run twice and some of these fail of course! 在这些文件夹中,当然没有包含引用,使相同的测试运行两次,其中一些当然失败!

Paths are related to build checkout directory, not to any working directory. 路径与构建结帐目录相关,而不是与任何工作目录相关。 If you need another paths, use %reference% syntax to refer to TeamCity property with a directory path. 如果需要其他路径,请使用%reference%语法通过目录路径引用TeamCity属性。 Do you run it under Windows? 你在Windows下运行吗? Do you use TeamCity 6.5? 你使用TeamCity 6.5吗?

If that does not help, feed free to contact teamcity-feedback@jetbrains.com 如果这没有帮助,请随时联系teamcity-feedback@jetbrains.com

In my case, the missing DLL was a native library and it could not be loaded because there was an incorrect version of VC runtime installed on the build agent. 在我的情况下,丢失的DLL是一个本机库,无法加载它,因为构建代理程序上安装了不正确的VC运行时版本。 My solution was to add runtime DLLs (located in 'C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\redist\\x86\\Microsoft.VC110.CRT') directly into the project (build action = Content, copy to output directory = Copy always). 我的解决方案是将运行时DLL(位于'C:\\ Program Files(x86)\\ Microsoft Visual Studio 11.0 \\ VC \\ redist \\ x86 \\ Microsoft.VC110.CRT')直接添加到项目中(构建操作=内容,复制到输出目录=始终复制)。 This also makes installation friendlier. 这也使安装更友好。

Hope this helps. 希望这可以帮助。

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

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