Question

In the scenario below, I expect that the assertion failure in the step should make the test fail. What I am seeing is that the test continues and since a later assertion in the @Test method fails, the wrong exception is being reported, making it hard to debug.

Is there anyway I can get the test to stop when there is an assertion failure in a @Step?

@Test
public void test() {
    ....
    steps.step1();

    System.out.println("test should not reach here");
    assertTrue(false);
}

@Step
public void step1() {
    assertTrue(false);
}

Tried running the tests from my IDE and maven. (using ThucydidesRunner)

Was it helpful?

Solution 2

It turns out the tests don't stop, here is the reply I got from the creators of Thucydides:

"The test can't stop immediately, or it would be impossible to know what steps were not executed, so, yes, this is by design. They do record the first assertion error and then run the steps in "dry-run" mode (no WebDriver calls are made), but that's about the most it can guarantee."

OTHER TIPS

try to check this: http://thucydides.info/docs/thucydides/_creating_a_new_thucydides_project.html

in short words, in steps:

import net.thucydides.core.annotations.Step;
import static org.fest.assertions.Assertions.assertThat;
import static org.hamcrest.Matchers.is;

public class EndUserSteps extends Scenario Steps {
@Step
public void someStep() {
   assertThat(true, is(false));
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top