Click here to Skip to main content
12,887,933 members (47,513 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# testing NUnit
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
    //some test code here

but I'm doing this

    int testValue=obj.getFoo();

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 24-Nov-12 4:40am
Updated 28-Nov-12 11:05am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100