mardi 25 août 2015

Dataproviders and Asserts

When using DataProviders, on TestNG, my test method has asserts that will fail since the data passed in navigates to a different url. Is there a way to work around this, i.e. a way for the data to only be injected to certain/specific asserts?


Instead of testing one scenario with different data, I am instead testing multiple scenarios with different data which is where my conflict arises.


@DataProvider(name = "VINNumbers")
public String[][] VINNumbers() {
    return new String[][] {
            {"2T1BU4ECC834670"},
            {"1GKS2JKJR543989"},
            {"2FTDF0820A04457"}
    };
}

@Test(dataProvider = "VINNumbers")
public void shouldNavigateToCorrespondingVinEnteredIn(String VIN) {

    driver.get(findYourCarPage.getURL() + VIN);
    Assert.assertTrue(reactSRP.dealerListingMSRPIsDisplayed());
}

The assert test whether or not the page has an MSRP displayed, but not all dataproviders will have an MSRP displayed so it will fail. The only dataprovider that has it is the first array. Is there a way for dataproviders to be called to specific asserts?



from Newest questions tagged java - Stack Overflow http://ift.tt/1Id1edz
via IFTTT

Aucun commentaire:

Enregistrer un commentaire