MbUnit - 使用 DependsOn 属性时,测试位于不同程序集中时的测试依赖性不起作用
我对 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简短的回答是,那行不通。
不幸的是,由于程序集的加载/隔离方式(默认情况下,在单独的进程中),很难实现您正在寻找的内容。
更好的错误消息会更好。
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.
您确实应该将所有测试放在一个程序集中(并将生产代码放在不同的程序集中)。这使得一切变得微不足道,包括依赖关系以及从生产代码中排除测试代码。
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.