下面列出了怎么用cucumber.api.java.en.Given的API类实例代码及写法,或者点击链接到github查看源代码。
@Given("(\\w+) (\\w+) is a registered trader$")
public void a_registered_trader(String firstName, String lastName) {
Actor trader = OnStage.theActorCalled(firstName);
trader.attemptsTo(
RegisterWithBDDTrader.asANewClient(Client.withFirstName(firstName)
.andLastName(lastName)
.andEmail(firstName + "@" + lastName + ".com"))
);
}
@Given("^variables: ([^\"]*)$")
public void graphqlVariablesFromFile(String file) throws IOException {
String fileName = configuration.classpathFile(file);
String graphqlVariables = expressions.evaluate(read(fileName));
assertNotNull(graphqlVariables);
assertFalse(graphqlVariables.isEmpty());
graphql.variables(graphqlVariables);
}
@Given("^I have two numbers: (.*) and (.*)$")
public void i_have_two_numbers(String a, String b) throws Throwable {
this.a = a;
this.b = b;
}
@Given("^I have two numbers: (.*) and (.*)$")
public void i_have_two_numbers(String a, String b) throws Throwable {
this.a = a;
this.b = b;
}
@Given("^I have two numbers: (.*) and (.*)$")
public void i_have_two_numbers(String a, String b) throws Throwable {
this.a = a;
this.b = b;
}
@Given("^I have two numbers: (.*) and (.*)$")
public void i_have_two_numbers(String a, String b) throws Throwable {
this.a = a;
this.b = b;
}
@Given("^I have two numbers: (.*) and (.*)$")
public void i_have_two_numbers(String a, String b) throws Throwable {
this.a = a;
this.b = b;
}
@Given("^I have two numbers: (.*) and (.*)$")
public void i_have_two_numbers(String a, String b) throws Throwable {
this.a = a;
this.b = b;
}
@Given("^I have two numbers: (.*) and (.*)$")
public void i_have_two_numbers(String a, String b) throws Throwable {
this.a = a;
this.b = b;
}
@Given("^(.*) quiere autenticarse$")
public void quiereAutenticarse(String actorName) {
theActorCalled(actorName).attemptsTo(
Open.browserOn(inicioSesionPage)
);
}
@Given("^catalogue with books$")
public void catalogue_with_books() {
assertTrue(bookRepository.count() > 0);
}
@Given("^([^\\\"]*) fixture is loaded$")
public void data_fixture_is_loaded(String fixtureName) throws Throwable {
ResourceDatabasePopulator populator = new ResourceDatabasePopulator(context.getResource("classpath:/" + fixtureName + ".sql"));
DatabasePopulatorUtils.execute(populator, ds);
}
@Given("^(\\d+) books available in the catalogue$")
public void books_available_in_the_catalogue(int bookCount) throws Throwable {
assertEquals(bookCount, bookRepository.count());
}
@Given("^Cesar wants to start versioning$")
public void startVersioning() {
theActorCalled(CESAR).wasAbleTo(
Start.authenticating(theUser(GITHUB_USER)
.withPassword(SECRET)));
}
@Given("^([^\\\"]*) fixture is loaded$")
public void data_fixture_is_loaded(String fixtureName) throws Throwable {
ResourceDatabasePopulator populator = new ResourceDatabasePopulator(context.getResource("classpath:/" + fixtureName + ".sql"));
DatabasePopulatorUtils.execute(populator, ds);
}
@Given("^(\\d+) books available in the catalogue$")
public void books_available_in_the_catalogue(int bookCount) throws Throwable {
assertEquals(bookCount, bookRepository.count());
}
@Given("^catalogue with books$")
public void catalogue_with_books() {
assertTrue(bookRepository.count() > 0);
}
@Given("^([^\\\"]*) fixture is loaded$")
public void data_fixture_is_loaded(String fixtureName) throws Throwable {
ResourceDatabasePopulator populator = new ResourceDatabasePopulator(context.getResource("classpath:/" + fixtureName + ".sql"));
DatabasePopulatorUtils.execute(populator, ds);
}
@Given("^(\\d+) books available in the catalogue$")
public void books_available_in_the_catalogue(int bookCount) throws Throwable {
assertEquals(bookCount, bookRepository.count());
}
@Given("^catalogue with books$")
public void catalogue_with_books() {
assertTrue(bookRepository.count() > 0);
}
@Given("^([^\\\"]*) fixture is loaded$")
public void data_fixture_is_loaded(String fixtureName) throws Throwable {
ResourceDatabasePopulator populator = new ResourceDatabasePopulator(context.getResource("classpath:/" + fixtureName + ".sql"));
DatabasePopulatorUtils.execute(populator, ds);
}
@Given("^(\\d+) books available in the catalogue$")
public void books_available_in_the_catalogue(int bookCount) throws Throwable {
assertEquals(bookCount, bookRepository.count());
}
@Given("^catalogue with books$")
public void catalogue_with_books() {
assertTrue(bookRepository.count() > 0);
}
@Given("^([^\\\"]*) fixture is loaded$")
public void data_fixture_is_loaded(String fixtureName) throws Throwable {
ResourceDatabasePopulator populator = new ResourceDatabasePopulator(context.getResource("classpath:/" + fixtureName + ".sql"));
DatabasePopulatorUtils.execute(populator, ds);
}
@Given("^wait: (\\d+)s times: (\\d+)$")
public void waitSecondsUntil(int seconds, int maxRetry) {
wait.configure(1000 * seconds, maxRetry);
}
@Given("(.*) Service is running")
public void checkServiceRunning(String serviceName) {
ResponseEntity<String> healthResponse = restTemplate.getForEntity("/health",String.class, new HashMap<>());
Assert.assertEquals(HttpStatus.OK, healthResponse.getStatusCode());
}
@Given("^I want to write a step with precondition$")
public void i_want_to_write_a_step_with_precondition() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Given("^some other precondition$")
public void some_other_precondition() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Given("^I want to write a step with name(\\d+)$")
public void i_want_to_write_a_step_with_name(int arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Given("^a trader with the following details:$")
public void a_trader_with_the_following_details(List<Client> clients) {
tim = OnStage.theActorCalled("Tim the trader");
client = clients.get(0); // We are only interested in a single client
}