开发者

MbUnit - test dependecy when tests are in different assemblies doesn't work when using DependsOn Attribute

开发者 https://www.devze.com 2023-02-16 08:33 出处:网络
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).

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开发者_如何学C 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消