Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm new to testing
For example I have a test (test1) that test if getFoo() return something and i have a more complex test (test2) that use one or more time getFoo()
I want the test2 to not start if test1 fails or at least to fail automatically without start testing.

I searched the documentation on Nunit for some attribute like [Require(someothertest)] but i couldn't find anything.


Sorry for my broken english, hope the question is understandable

I'm not doing this
C#
test1(){
    //some test code here
    test2();
}


but I'm doing this

test1(){
    Assert(obj.getFoo()>0);
}
test2(){
    int testValue=obj.getFoo();
    Assert(obj.doSomething(testValue)>=0);
}

this is just an example
but as can you see test2 use obj.getFoo(), so if test1 fails i know getFoo() don't work correctly but getFoo may return a value that make test2 pass anyway, so I want that if test1 fails, test2 must not be tested or must automatically fail since it's not an attendible test

I hope i explained myself a little better :)
Posted
Updated 28-Nov-12 11:05am
v3

1 solution

First of all...its a bad practice to call a test method in another test method.There should not be any dependencies among the test methods
Those should be able to execute independently.

If you want to do it, probably one has to put check before Assert
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900