lambda-behave
lambda-behave copied to clipboard
Failure tests behaviour
Let's say I have the following test class:
@RunWith(JunitSuiteRunner.class)
public class StackSpec {{
Stack<Integer> stack = new Stack<>();
List<Integer> list = new ArrayList<>();
describe("a stack", it -> {
it.isSetupWith(stack::clear);
it.isConcludedWith(stack::clear);
// First test executed
it.should("be not empty when created", expect -> {
stack.add(1);
expect.that(stack).isEmpty(); // Will fails
});
// Second test but never executed
it.should("be empty when created", expect -> {
expect.that(stack).isEmpty();
});
}
describe("a list", it -> {
it.isSetupWith(list::clear);
it.isConcludedWith(list::clear);
// Third test but never executed
it.should("be empty when created", expect -> {
expect.that(list).isEmpty();
});
}
}}
If one test fails, all others won't be executed from the Test class. Is there a way to prevent this to happen and still continue others tests ?
Hi, @martiwi , you have the same "be empty when created" in different describe blocks. There is a simple workaround - just rename one of them.