cucumber.api.java.en.Then Java Examples
The following examples show how to use
cucumber.api.java.en.Then.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StepDefinitions.java From demo-java with MIT License | 5 votes |
@Then("I have (\\d) items? in my cart") public void one_item_in_cart(Integer items) { String expected_items = items.toString(); By itemsInCart = By.className("shopping_cart_badge"); wait.until(ExpectedConditions.elementToBeClickable(getDriver().findElement(itemsInCart))); Assert.assertEquals(getDriver().findElement(itemsInCart).getText(), expected_items); }
Example #2
Source File: ShoppingCartSteps.java From serenity-cucumber-bdd-screenplay with Apache License 2.0 | 5 votes |
@Then("^he should see the total cost including shipping:$") public void he_should_see_the_total_cost_including_shipping(DataTable arg1) { theActorInTheSpotlight().attemptsTo(ProceedToCheckOut.fromCartSummaryPopup()); theActorInTheSpotlight().attemptsTo(ProceedToCheckOut.fromCheckoutSummary()); theActorInTheSpotlight().should( seeThat(Checkout.totalPrice(), containsString(arg1.raw().get(1).get(2))) ); }
Example #3
Source File: SearchItemsSD.java From serenity-cucumber-bdd-screenplay with Apache License 2.0 | 5 votes |
@Then("^s?he should see the list of (.*) with prices available for sale$") public void she_should_see_the_list_of_items_with_prices_available_for_sale(List<String> items) { theActorInTheSpotlight().should( seeThat(SearchResults.resultsGrid(), is(Available)), seeThat(SearchResults.checkForTitle(), containsString("product")), seeThat(SearchResults.price(), is(Available)) ); }
Example #4
Source File: StringVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)}!=\"([^\"]*)\"$") public void verifyVariableNotEqualsString(String expression, String expected) { assertThat(variables.get(expression), not(expressions.evaluate(expected))); }
Example #5
Source File: FloatVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: '([^\"]*)'=float: (\\d+\\.\\d+)$") public void verifyEqualsFloat(String path, String expected) throws Throwable { assertThat(actual.json(path), is(parseFloat(expected))); }
Example #6
Source File: LongVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: '([^\"]*)'>long: ([^\"]*)$") public void verifyGreaterThanLong(String path, String expected) throws Throwable { assertThat((Long) actual.json(path), greaterThan(parseLong(expected))); }
Example #7
Source File: DecimalVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)}!=decimal: ([^\"]*)$") public void verifyVariableNotEqualsDecimal(String expression, String expected) { assertNotEquals(0, ((BigDecimal) variables.get(expression)).compareTo(new BigDecimal(expected))); }
Example #8
Source File: CucumberTestSteps.java From Cloud-Native-Applications-in-Java with MIT License | 4 votes |
@Then("^return a (\\d+) not found status$") public void return_a_status(int status) throws Throwable { Assert.assertEquals(HttpStatus.NOT_FOUND, errResponse.getStatusCode()); }
Example #9
Source File: FloatVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)}>=float: (\\d+\\.\\d+)$") public void verifyVariableGreaterThanOrEqualToFloat(String expression, String expected) { assertThat((Float) variables.get(expression), greaterThanOrEqualTo(parseFloat(expected))); }
Example #10
Source File: IntegerVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: '([^\"]*)'<=(\\d+)$") public void verifyLessThanOrEqualToInteger(String path, final int expected) throws Throwable { assertThat((int) actual.json(path), lessThanOrEqualTo(expected)); }
Example #11
Source File: CucumberTestSteps.java From Cloud-Native-Applications-in-Java with MIT License | 4 votes |
@Then("^return error message \"(.*)\"$") public void return_error_message_indicating_product_is_not_found(String errMsg) throws Throwable { Assert.assertTrue(errResponse.getBody().contains(errMsg)); }
Example #12
Source File: StringVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: '([^\"]*)' length: (\\d+)$") public void verifyStringLength(String path, int length) throws Throwable { assertThat(String.valueOf(toBeVerified.json(path)).length(), is(length)); }
Example #13
Source File: StringVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: '([^\"]*)' matches: '([^\"]*)'$") public void verifyMatchesRegex(String path, String regex) throws Throwable { assertTrue(String.valueOf(toBeVerified.json(path)).matches(regex)); }
Example #14
Source File: CucumberTestSteps.java From Cloud-Native-Applications-in-Java with MIT License | 4 votes |
@Then("^return a (\\d+) not found status$") public void return_a_status(int status) throws Throwable { Assert.assertEquals(HttpStatus.NOT_FOUND, errResponse.getStatusCode()); }
Example #15
Source File: FloatVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)}=float: (\\d+\\.\\d+)$") public void verifyVariableEqualsFloat(String expression, String expected) { assertThat(variables.get(expression), is(parseFloat(expected))); }
Example #16
Source File: CucumberTestSteps.java From Cloud-Native-Applications-in-Java with MIT License | 4 votes |
@Then("^return error message \"(.*)\"$") public void return_error_message_indicating_product_is_not_found(String errMsg) throws Throwable { Assert.assertTrue(errResponse.getBody().contains(errMsg)); }
Example #17
Source File: DecimalVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)}>=decimal: ([^\"]*)$") public void verifyVariableGreaterThanOrEqualToDecimal(String expression, String expected) { assertTrue(((BigDecimal) this.variables.get(expression)).compareTo(new BigDecimal(expected)) >= 0); }
Example #18
Source File: CodeVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)}!=code:$") public void verifyVariableNotEqualsCodeBlock(String expression, String code) throws ScriptException { assertThat(variables.get(expression), not(eval(expressions.evaluate(code)))); }
Example #19
Source File: DoubleVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: '([^\"]*)'=double: (\\d+\\.\\d+)$") public void verifyEqualsDouble(String path, String expected) throws Throwable { assertThat(actual.json(path), is(parseDouble(expected))); }
Example #20
Source File: DecimalVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: '([^\"]*)'>decimal: ([^\"]*)$") public void verifyGreaterThanDecimal(String path, String expected) throws Throwable { assertEquals(1, ((BigDecimal) actual.json(path)).compareTo(new BigDecimal(expected))); }
Example #21
Source File: StringVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)} ends with: '([^\"]*)'$") public void verifyVariableEndsWithLiteral(String expression, String prefix) { assertThat(String.valueOf(variables.get(expression)), endsWith(prefix)); }
Example #22
Source File: BooleanVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)}=(true|false)$") public void verifyVariableEqualsBoolean(String expression, String expected) { assertThat(variables.get(expression), is(Boolean.valueOf(expected))); }
Example #23
Source File: HttpSteps.java From pandaria with MIT License | 4 votes |
@Then("^response header: '([^\"]*)'='([^\"]*)'$") public void verifyResponseHeader(String key, String expected) { List<String> values = context.responseHeader(key); assertNotNull(values); assertThat(join(",", values), is(expected)); }
Example #24
Source File: HttpSteps.java From pandaria with MIT License | 4 votes |
@Then("^response body: ([^\"]*)$") public void verifyResponseBodyAgainstFile(String file) throws IOException { String content = expressions.evaluate(read(configuration.classpathFile(file))); assertThat(context.responseBody(), is(content)); }
Example #25
Source File: DebugSteps.java From pandaria with MIT License | 4 votes |
@Then("^print: \"([^\"]*)\"$") public void printExpression(String printing) { System.out.println(expressions.evaluate(printing)); }
Example #26
Source File: JsonVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)} contains json: ([^\"]*)$") public void variableContainsJsonFromFile(String expression, String fileName) throws IOException { assertThat(variables.get(expression), jsonEquals(fileContent(fileName)) .when(IGNORING_ARRAY_ORDER, IGNORING_EXTRA_ARRAY_ITEMS, IGNORING_EXTRA_FIELDS)); }
Example #27
Source File: WebSteps.java From Test-Driven-Java-Development-Second-Edition with MIT License | 4 votes |
@Then("^the page title contains (.*)$") @org.jbehave.core.annotations.Then("the page title contains $title") public void pageTitleIs(String title) { assertThat(title(), containsString(title)); }
Example #28
Source File: JsonVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)} has size: (\\d+)$") public void variableHasSize(String expression, Integer size) { assertThat(size(variables.get(expression)), is(size)); }
Example #29
Source File: CodeVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)}!=code file: ([^\"]*)$") public void verifyVariableNotEqualsInFile(String expression, String file) throws IOException, ScriptException { assertThat(variables.get(expression), not(eval(expressions.evaluate(read(configuration.classpathFile(file)))))); }
Example #30
Source File: FloatVerificationSteps.java From pandaria with MIT License | 4 votes |
@Then("^verify: \\$\\{([^\"]*)}!=float: (\\d+\\.\\d+)$") public void verifyVariableNotEqualsFloat(String expression, String expected) { assertThat(variables.get(expression), not(parseFloat(expected))); }