jeudi 23 août 2018

Inheritace common test steps from base class

    When writing test cases for end-to-end test scenarios using java, selenium, java; we can keep common steps into the base class method and specific add, edit steps in the specific class.

    public abstract class XXXXBaseTest extends SeleniumTest { 

    @Test
    public void validateCalendarUi() throws IOException {
            **ExpCalendar expCalendar = openExpCalendar();**

            String calenderAvailable = expCalendar.getHeaderViewText();
            Assert.assertEquals(calenderAvailable, "Calendar View", "Failed : Calendar is not available");
    }
    }

Then, opened calendar() method is overridden in each specific class with specific steps.

public class XXXXXViewExpirationCalendarTest extends RefDataExpirationCalendarTest {

@Override
protected ExpCalendar openExpCalendar() {
        //Here write specific methods
}

}

Is this appropriate approach for test scripting?.Can we use inheritance concept to write test cases in this way ?

Aucun commentaire:

Enregistrer un commentaire