How to write step definition in cucumber?
Java class is used for writing step definition file. This execute each given steps in feature file. We have to write a method for each step in step definition java class with same annotation and with the same steps given in feature file. Each step associate to one method which get executed.Annotation is step definition
Below are the lists of annotations which are generally used in feature file and same are used in step definition.@Given
@When
@Then
@And
@But
While writing step definition, we have to make sure the steps written in feature file, it should be same in step definition. Such as example given below.
Step in Feature file
Given This is a book
Step definition
@Given (“^This is a book$”)
Public void method1()
{
System.out.println(“test”);
}
Some related topics :-
No comments:
Post a Comment