简体   繁体   中英

NUnit Error: Not a test assembly

I have a solution with 3 projects in it (one is a C# class-library for unit tests, another is a MVC 2 web application)

I have included all the necessary references for NUnit, and I have correctly decorated the classes and methods with [TestFixture] and [Test] respectively.

It compiles with no errors.

I am using Visual Studio 2010 Pro

When I try to open UnitTests.dll in NUnit, I get the following error:

Not a test assembly. This assembly was not built with any known testing framework.

This may or may not be the issue that you are facing, but I had exactly the same issue and I found that the dll I was loading was an old file.

Rebuild the project and then actually go into the directory that the dll is in and check that it has a creation/modification time that is current.

It's very easy, for example, to create:

my_project/
my_project/domain/
my_project/unit-tests/ (removed but not deleted on the HD, not visible in studio)
my_project/domain/unit-tests/ (visible as MyProject.UnitTests)

If you then load the dll in my_project/unit-tests/ you may not be loading the dll you just built.

Try also file -> save as while editing a test class, and see what actual directory it is being saved into, and check that the dll you are loading is from the same path.

Is there a reference to the assembly in the GAC? Take a look in tools > test assemblies of the NUnit GUI runner as per this blog posting:

http://blog.solien.com/archive/2010/02/09/unable-to-load-unit-test-the-assembly-was-not.aspx

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