mercredi 27 juillet 2016

How can we pass a reference type in the Returns() method of TestCaseDataSource Nunit?

Example:

[Test, TestCaseDataSource("MyDataSource")]

public TestClass TestMyMethod(TestCaseData testData)
{
    ---Do some stuff---
    return TestClass;
}

public IEnumerable<TestCaseData> MyDataSource()

{

yield return new TestCaseData("test").Returns(new TestClass(){--some params--}.SetName("MyTestCaseScenario"));

}

Aucun commentaire:

Enregistrer un commentaire