How do I get a description of a test case?

I have a nunit test with some test cases.

[TestCase(1,Description="first")]
[TestCase(2, Description="second")]
public void A(int a)
{
    Assert.True(a==1);
}

      

How can I get a description of each test case. I am trying to do this with TestFinished () EventListener method, but I can only get an array of descriptions.

+4


source to share


2 answers


Have you tried NUnit CurrentContext ?



Perhaps (I haven't looked) the Description value is in TestContext.CurrentContext.Test.Properties, you need at least NUnit 2.6.2, see NUnit 2.6.2 TestContext.CurrentContext is always null

+1


source


I think you should see this answer here

But when I tried what is mentioned in this answer it gave me the property list object itself which is not needed, it worked fine with me when I used instead:



TestContext.CurrentContext.Test.Properties.Get("Description")

      

I hope this works with you too

0


source







All Articles