mardi 12 avril 2016

How can I use automated integration tests across multiple frameworks (internet browsers) without duplicating effort?

To give more detail, we have a series of tests we want duplicated across three frameworks: IE, Mozilla, and Chrome. The first solution was to duplicate the tests in separate test classes, i.e. each test class had the same 20 test cases with a different framework in the constructor. The second solution was to use parameterized inputs (or an XUnit theory) with each framework type as an input:

    /// <summary>
    /// The non-default constructor that initializes
    /// necessary instances of objects that are being used
    /// </summary>
    public VerifyViewUsingChrome() {
        _testBases = new Dictionary<FunctionalTestBase.DriverType, TestBase>();
        _testBases.Add(FunctionalTestBase.DriverType.Chrome, new TestBase(FunctionalTestBase.DriverType.Chrome));
        _testBases.Add(FunctionalTestBase.DriverType.IE, new TestBase(FunctionalTestBase.DriverType.IE));
        _testBases.Add(FunctionalTestBase.DriverType.FireFox, new TestBase(FunctionalTestBase.DriverType.FireFox));
    }


    /// <summary>
    /// Our simple country display test.
    /// </summary>
    [InlineData(FunctionalTestBase.DriverType.Chrome)]
    [InlineData(FunctionalTestBase.DriverType.FireFox)]
    [InlineData(FunctionalTestBase.DriverType.IE)]
    [Theory]
    public void TestADisplayedForACountry(FunctionalTestBase.DriverType testBase) {
        _testBases[testBase].TestADisplayedForACountry();
    }

The issue with this implementation is that all 3 implementations have to be running for each test, which requires some overhead. Ideally, we would run all the IE tests, then build the Firefox framework and run those tests before continuing on with Chrome.

It may not be possible using a test framework, but for we have convenient tie-ins with our build server, so keeping the test format would be ideal.

Aucun commentaire:

Enregistrer un commentaire