简体   繁体   中英

FileNotFoundException when running NUnit tests from TeamCity

I am using the built in TeamCity NUnit runner to run tests stored in .DLL files.

My .DLLs are referencing other DLLs which are present in the same folder.

When running these, i am getting a FileNotFoundException for the referenced DLLs.

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...

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:

**/*.Tests.dll

This means that it will include tests from /bin/Debug/ and also from other folders, such as 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. Do you run it under Windows? Do you use TeamCity 6.5?

If that does not help, feed free to contact 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. 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). This also makes installation friendlier.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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