MbUnit - 使用 DependsOn 属性时,测试位于不同程序集中时的测试依赖性不起作用

发布于 2024-10-21 21:06:48 字数 722 浏览 3 评论 0原文

我对 DependsOn 属性有一个奇怪的问题。 我在程序集 ASSM_A 中定义了测试 A,在 ASSM_B 中定义了测试 B(两者都是测试装置)。 当我定义测试 B 对测试 A 的依赖关系时:

[TestFixture]
[DependOn(ASSM_A_NAMESPACE.A)]
public class B
{
    // my code .....
}

一切正常并在 .NET 中编译(VS 2008,MbUnit 版本 = 3.2.0.0,Gallio 版本 = 3.2 build 601)。

但是,当我在 Gallio 中加载程序集 ASSM_A 和 ASSM_B 并运行测试 B(取决于测试 A)时,我收到以下消息:

[warning] Was unable to resolve a test dependency.

当两个测试都在同一个程序集中时 - 依赖项按预期工作。

可能是什么问题?也许我应该定义自定义依赖属性,以防测试位于不同的程序集中?如果是这样,任何人都可以解释如何做到这一点吗?

多谢!

PS:编码是用C#完成的。

PSS:阅读 AssemblyDependsOn 但无法使用它,因为它是旧的 MbUnit 阅读有关 DependsOnAssembly (与 AssemblyDependsOn 基本相同)的信息,但在我正在使用的 MbUnit 版本中找不到 int 。

I have this weird problem with DependsOn attribute.
I have a test A defined in Assembly ASSM_A and test B defined in ASSM_B (both are test fixtures).
When I define a dependency of test B on test A:

[TestFixture]
[DependOn(ASSM_A_NAMESPACE.A)]
public class B
{
    // my code .....
}

everything works and compiles in .NET (VS 2008, MbUnit version = 3.2.0.0, Gallio version = 3.2 build 601).

But when I load both assemblies ASSM_A and ASSM_B in Gallio and run test B (which depends on test A) I get the following message:

[warning] Was unable to resolve a test dependency.

When both tests are in the same assembly - dependency works as it is supposed to.

What might be the problem ? Maybe I should define my custom dependency attribute in case tests are in different assemblies ? If so, can anyone explain how to do so ?

Thanks a lot!

P.S.: Coding is done in C#.

P.S.S.: Read about AssemblyDependsOn but can't use it since it is old MbUnit
Read about DependsOnAssembly (which is basically the same as AssemblyDependsOn) but couldn't find int in MbUnit version that I am using.

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

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

发布评论

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

评论(2

海夕 2024-10-28 21:06:49

简短的回答是,那行不通。

不幸的是,由于程序集的加载/隔离方式(默认情况下,在单独的进程中),很难实现您正在寻找的内容。

更好的错误消息会更好。

The short answer is, that won't work.

Unfortunately, due to the way assemblies are loaded/isolated (by default, in a separate process), it would be quite hard to achieve what you're looking for.

A better error message would be good.

暖风昔人 2024-10-28 21:06:49

您确实应该将所有测试放在一个程序集中(并将生产代码放在不同的程序集中)。这使得一切变得微不足道,包括依赖关系以及从生产代码中排除测试代码。

DependsOn 可以很好地处理单个程序集中的测试,因此我建议您切换到此方式。

You should really have all of your tests in a single assembly (and your production code in a different assembly). This makes everything trivial, including dependencies and excluding test code from production code.

DependsOn works fine with tests within a single assembly, so I suggest you switch to this.

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