How to mark the whole class as "Unspecific"?

I have a test class called MyClass. MyClass has a TestFixtureSetUp that loads some raw data. I want to mark the whole class as Inconclusive when loading the source data. Just like when someone marks the Inconclusive test method by calling Assert.Inconclusive ().

Is there any solution?

+3
source share
2 answers

Try the following:

  • In, TestFixtureSetUpsave a static value in the class to indicate whether the data was still loaded, was loaded successfully, or was attempted, but failed to load.

  • In your SetUptest for each test value.

  • , , Assert.Inconclusive().

+3

Setup, .

:

[TestFixture]
public class ClassWithDataLoad
{
    private bool loadFailed;

    [TestFixtureSetUp]
    public void FixtureSetup()
    {
        // Assuming loading failure throws exception.
        // If not if-else can be used.
        try 
        {
            // Try load data
        }
        catch (Exception)
        {
            loadFailed = true;
        }
    }

    [SetUp]
    public void Setup()
    {
        if (loadFailed)
        {
            Assert.Inconclusive();
        }
    }

    [Test] public void Test1() { }        
    [Test] public void Test2() { }
}

Nunit Assert.Inconclusive() TestFixtureSetUp. Assert.Inconclusive() , .

+6

Source: https://habr.com/ru/post/1727136/


All Articles