lundi 2 mars 2020

Can we write code inside CollectionDefinition class

public class MyFirstFixture : IDisposable
{
    public MySecondFixture()
    {
        // Some initialization
    }

    public void Dispose()
    {
        // Some cleanup
    }
}

[CollectionDefinition("MyCollection")]
public class MyCollectionDefinition : ICollectionFixture<MyFirstFixture>
{
    //Can I add code in this section?
}

[Collection("MyCollection")]
public class TestClass1
{
    [Fact]
    public void TestMethod1()
    {
        // Do some testing
    }
}

Here I have defined MyFirstFixture and created a collection definition with CollectionFixture and that collection name is being used in tests. Can I write the code in the CollectionDefinition section as well? Will that get executed whenever the collection is mentioned in a test?

Aucun commentaire:

Enregistrer un commentaire