lambda-behave icon indicating copy to clipboard operation
lambda-behave copied to clipboard

Failure tests behaviour

Open martiwi opened this issue 7 years ago • 1 comments

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 ?

martiwi avatar Mar 14 '18 10:03 martiwi

Hi, @martiwi , you have the same "be empty when created" in different describe blocks. There is a simple workaround - just rename one of them.

dimiii avatar Nov 06 '18 15:11 dimiii