Search code examples
junitcucumber-jvm

How to make a test case as fail in Junit?


When i use fail()[Junit] in the script, the scripts stops running and Skipped the next steps.

 In TestNG, We can do that using "org.testng.Assert.fail("");" .

my requirement is to continue to run the next scenario even if my previous case was failure .

Please help me .


Solution

  • You need to use soft asssertions. Something like this

    public static void verifyFalse(boolean condition) {
        try {
            assertFalse(condition);
    } catch(Throwable e) {
            e.printStackTrace();
            throw new YourException("your message");
    }