NUnit的错误:没有一个测试组件 [英] NUnit Error: Not a test assembly

查看:433
本文介绍了NUnit的错误:没有一个测试组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在这3个项目的解决方案(一个是C#类库单元测试,另一种是MVC 2 Web应用程序)

我已经包括了所有的NUnit必要的参考,我已经正确装饰类和方法与 [的TestFixture] [测试] 分别。

它编译没有任何错误。

我使用Visual Studio 2010专业版

当我尝试在NUnit的打开UnitTests.dll,我得到以下错误:


  

不是一个测试组件。
  该组件不是建立与任何已知的测试框架。



解决方案

这可能是也可能不是你所面临的问题,但我有完全一样的问题,我发现我是加载DLL是一个旧文件

重建项目,然后真正去到该dll是目录,并检查它有一个创建/修改时间是最新的。

这很容易,比如,创建:

  MY_PROJECT /
MY_PROJECT /域/
MY_PROJECT /单元测试/(删除,但不删除对HD,在工作室中不可见)
MY_PROJECT /域/单元测试/(如MyProject.UnitTests可见)

如果你再加载MY_PROJECT /单元测试的dll /你可能不会加载您刚刚构建的DLL。

也试着文件 - >另存为,同时编辑一个测试类,看看实际的目录的它被保存到,并检查正在加载的DLL是从同一个路径

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.

这篇关于NUnit的错误:没有一个测试组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆