mardi 29 août 2017

Android Unit tests with multiple predefined varibales

Usually I develop using C# with the NUnit-Framework. With the help of it, several sets of Varibales can be easily tested, this is especially useful if you have functions with several configurations.

This is an example:

[TestCase("0", 1)]
[TestCase("1", 1)]
[TestCase("2", 1)]
public void UnitTestName(string input, int expected)
{
    //Arrange

    //Act

    //Assert
}

of course it would be even better if i could try several combinations, in C# this is achieved like

    public void UnitTestName(
      [Varibale("2", "1")] string input,
      [Varibale(2, 1)] int expected)
    {
        //Arrange

        //Act

        //Assert
    }

Thank you very much in advance!

Aucun commentaire:

Enregistrer un commentaire