Problem
I am working on a UI framework which needs the methods and the page objects to be called dynamically in a sequence based on the input sequence. I mainly want to substitute the Switch / If else with a better OO way to make it easier for extension
All the pages extend a Base Abstract class and the methods extend another base Action class. I have annotations to identify classes and the methods. I need to build a list of methods which will be invoked by the framework in the same order for each test case.
I am using BDD for the input i.e.
Scenario : Test the transaction successful page
- Given user logsin
- And performs some actions
- Then the transaction successful page is displayed
So, each step is mapped to a Action class which performs a set of Actions. I am using annotations to find the Action class.
//Sample JBehave Steps Pojo
@Given
public void login(String user)
{
//Action to be performed is Login. Search for the Login Action class
}
@And
public void performSomeAction(String action , String component)
{
Find the class representing this action
}
//Page Objects
ClassMap(name="loginPage")
public class LoginPage extend Page
{
MethodMap(action="test" , component="test")
public BaseStep login extends BaseStep
{
// returns a login step
}
}
//Building the method sequence
//Now each Test Step is mapped to a class
for(Action : Actions to be performed)
{
//Check if the action / component maps to a method and a class
switch(action)
{
case VERIFY:
//Invoke the Method Verify
case LOAD :
//Invoke the Method Load
case ACTION1 :
//Perform some action
}
I am looking for a design pattern to implement the same without using switch else. A good design pattern which would fit in is what I would be looking at.
Aucun commentaire:
Enregistrer un commentaire