NUnit 错误:不是测试程序集

发布于 2024-10-06 08:33:35 字数 333 浏览 3 评论 0原文

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

我已经包含了 NUnit 的所有必要引用,并且我已经用 < 正确地装饰了类和方法分别为 code>[TestFixture] 和 [Test]

它编译没有错误。

我正在使用 Visual Studio 2010 Pro

当我尝试在 NUnit 中打开 UnitTests.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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨落星ぅ辰 2024-10-13 08:33:35

这可能是也可能不是您面临的问题,但我遇到了完全相同的问题,并且我发现我正在加载的 dll 是一个旧文件。

重建项目,然后实际进入 dll 所在的目录并检查它的创建/修改时间是否是最新的。

例如,创建起来非常简单:

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)

如果您随后将 dll 加载到 my_project/unit-tests/ 中,您可能不会加载刚刚构建的 dll。

也尝试文件 ->在编辑测试类时另存为,并查看它被保存到的实际目录,并检查您正在加载的 dll 是否来自同一路径。

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.

梦旅人picnic 2024-10-13 08:33:35

是否提及 GAC 大会?看看工具>按照此博客文章测试 NUnit GUI 运行程序的程序集:

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文