Skip to content

Test Information Attribute

Tom Longhurst edited this page Apr 27, 2020 · 2 revisions

The [TestInformation] attribute is designed for including extra relevant bits of information in the test report.

This attribute can be used as is, or inherited. It takes a string, and this will be output on the generated report.

Basic Example

[Test]
[TestInformation("Test for bug #12345")]
public void Test1()
{
    Given(() => Action1())
        .When(() => Action2())
        .Then(() => Assertion1())
        .And(() => Assertion2())
        .BDTest();
}

Inherited Example

    public class BugInformationAttribute : TestInformationAttribute
    {
        public BugInformationAttribute(string bugNumber) : base($"Bug #{bugNumber} - http://www.mybugtrackingsite.com/bugs/{bugNumber}")
        {
        }
    }

An used on the test like

[Test]
[BugInformation("12345")]
public void Test1()
{
    Given(() => Action1())
        .When(() => Action2())
        .Then(() => Assertion1())
        .And(() => Assertion2())
        .BDTest();
}
Clone this wiki locally