assertThat("stats-duration", fromId("stats-duration-Account Holder withdraws cash", doc).text(), is("112 ms"));
assertNotNull(fromId("stats-duration-Account Holder withdraws cash", doc));
}
private void assertFeatureContent(Document doc) {
Elements elements = doc.select("div.passed");
assertThat("feature-keyword", elements.select("div.feature-line span.feature-keyword").first().text(), is("Feature:"));
assertThat("feature-text", elements.select("div.feature-line").first().text(), is("Feature: Account Holder withdraws cash"));
assertThat("feature-description", doc.select("div.feature-description").first().text(),
is("As a Account Holder I want to withdraw cash from an ATM So that I can get money when the bank is closed"));
assertThat("scenario-background-keyword", doc.select("div.passed span.scenario-keyword").first().text(), is("Background:"));
assertThat("scenario-background-name", doc.select("div.passed span.scenario-name").first().text(), is("Activate Credit Card"));
elements = doc.select("div.passed span.step-keyword");
List<String> backgroundStepKeywords = new ArrayList<String>();
List<String> firstScenarioStepKeywords = new ArrayList<String>();
for (Element element : elements) {
int index = elements.indexOf(element);
if (index < 3) {
backgroundStepKeywords.add(element.text());
} else if (index >= 3 && index < 10) {
firstScenarioStepKeywords.add(element.text());
} else {
break;
}
}
assertThat("Background step keywords must be same", backgroundStepKeywords, is(Arrays.asList(new String[] {"Given", "When", "Then"})));
assertThat("First scenario step keywords must be same", firstScenarioStepKeywords,
is(Arrays.asList(new String[] {"Given", "And", "And", "When", "Then", "And", "And"})));
elements = doc.select("div.passed span.step-name");
List<String> backgroundStepNames = new ArrayList<String>();
List<String> firstScenarioStepNames = new ArrayList<String>();
for (Element element : elements) {
int index = elements.indexOf(element);
if (index < 3) {
backgroundStepNames.add(element.text());
} else if (index >= 3 && index < 10) {
firstScenarioStepNames.add(element.text());
} else {
break;
}
}
assertThat("Background step names must be same", backgroundStepNames,
is(Arrays.asList(new String[] {
"I have a new credit card",
"I confirm my pin number",
"the card should be activated"})));
assertThat("First scenario step names must be same", firstScenarioStepNames,
is(Arrays.asList(new String[] {
"the account balance is 100",
"the card is valid",
"the machine contains 100",
"the Account Holder requests 10",
"the ATM should dispense 10",
"the account balance should be 90",
"the card should be returned"})));
elements = doc.select("div.passed span.step-duration");
// assertFalse("step durations must not be empty", elements.isEmpty());
List<String> stepDurations = new ArrayList<String>();
for (Element element : elements) {
stepDurations.add(element.text());
int index = elements.indexOf(element);
if (index >= 10) break;
}
assertThat("Step durations must be same", stepDurations,
is(Arrays.asList(new String [] {"107 ms", "0 ms", "0 ms", "0 ms", "0 ms", "0 ms", "0 ms", "3 ms", "0 ms", "0 ms", "0 ms"})));
}