lundi 6 juillet 2020

Running tests for different environment and different versions C#-MSTest

I am creating an automated test framework to test an API using .NetCore, RestSharp and MsTest. I am looking for ideas to run my tests for 4 different environments (2 different countries, test and live environment each). I will access test data through appsettings.json file (e.g appsettings.eutest.json, appsetings.detest.json, etc).

I could use something like [DynamicData()] to pass each test an argument with the key to access each individual .json file, but there is a subset of tests, compatibility tests, where I need to run also again different versions of the API, this is needed to ensure backward compatibility.

    [DynamicData("NameOfPropertyWithEnvironments", typeof(BaseClass))]
    [TestMethod]
    public void RegularTest(string envToTest)
    {
        //-- Logic to access data on the .json file
    }

    [DynamicData("NameOfPropertyWithVersions", typeof(BaseClass))]
    [TestMethod]
    public void CompatibilityTest(int versionBackToTest)
    {

    }

So far, I have been using also [DynamicData()] to pass the versions to be tested as an argument of those particular tests, but I am lost as to how to combine different environments and different versions.

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire