Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save bcarun/484445cccb6f0a0375a3f56442d0d6cd to your computer and use it in GitHub Desktop.

Select an option

Save bcarun/484445cccb6f0a0375a3f56442d0d6cd to your computer and use it in GitHub Desktop.
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import cucumber.api.java8.En;
import io.cucumber.datatable.DataTable;
import io.restassured.response.Response;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.arun.cucumber.crudusingdatatable.employee.Employee;
import org.arun.cucumber.crudusingdatatable.employee.Phone;
/**
* Step Definition Class for Employee.
*
* <p>Uses Java Lambda style step definitions so that we don't need to worry
* about method naming for each step definition.</p>
*
* <p> Step definitions use Cucumber Expression.</p>
*/
public class EmployeeSteps extends AbstractSteps implements En {
public EmployeeSteps() {
// 1. Same step definition being used for create and update use cases
// 2. Text within 'paranthesis - ()' is considered optional and will not be used to match step definition
// 3. Text separated by 'forward slash - /' means either create or update is considered a match
Given("(user wants to create/update )an employee with the following attributes", (DataTable employeeDt) -> {
//Code to convert DataTable to Java Object
List<Employee> employeeList = employeeDt.asList(Employee.class);
// Implementation Goes Here
});
And("with the following phone numbers", (DataTable phoneDt) -> {
//Code to convert DataTable to Java Object
List<Phone> phoneList = phoneDt.asList(Phone.class);
// Implementation Goes Here
});
When("user saves the new employee {string}", (String testContext) -> {
// Implementation Goes Here
});
// Same step definition being used to assert save, get and delete employee
Then("the save/get/delete {string}", (String expectedResult) -> {
// Implementation Goes Here
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment