Why is there no xUnit.net FactAttribute AttributeUsage.Inheritable?

Before writing the structural structure of testing, it seems to me that an inherited attribute of fact will simplify work with abstract test classes or test interfaces, if some types in the assembly should be tested for similar things.

Is there a design reason that Fact is not inherited? I think other test environments (NUnit, MSTest, MbUnit, etc.) that use attributes to identify test methods have also been developed. What am I missing?

This is where the FactAttribute action for xunit begins (version 1.9.1.1600):

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class FactAttribute : Attribute
{

I am trying to understand why this does not look like this:

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class FactAttribute : Attribute
{ 
+5
source share
3 answers

, , . , [Fact] .

+1

( , ), xUnit.net.

public abstract class TestBase
{
    [Fact]
    public void Verify()
    {
        // Step 1
        // Step 2

        // Overridable step 3
        DoStuff();

        // Assert
    }

    protected abstract void DoStuff();
}

public class Test1 : TestBase
{
    protected override void DoStuff()
    {
        // Test1 variation
    }
}

public class Test2 : TestBase
{
    protected override void DoStuff()
    {
        // Test2 variation
    }
}

- Test1 Test2.

, .

+1

All Articles