I'm using Cucumber + Java + Selenium to UI test an application.

I'm using the same set of tests whether my application is deployed in qualification (for tests) or in production.

However, when I'm in production, I would like to stop my tests sooner (as to not save the data I just changed in my test).

So, is there a way to make a cucumber test scenario stop and exit with success even though all the steps weren't played?

I have found this answer who is useful. However, I'm using JUnit 5 (not 4 like in the answer) and if I try using:

import org.junit.jupiter.api.Assumptions;


My test exit with an error.

I have though about using System.exit(0);. However, this exit everything without execution the @After of my test (so my test don't end really cleanly) and all the tests scenarios that were supposed to be played after are skip! (nb: I just want to skip the remaining steps, not scenarios.)

So, is there a way that I can skip some test's steps, exit the test scenario with success and happily go to the next test scenario (without having everything ending like it's the case when using "System.exit")?

1 Answer 1


Turns out that JUnit 5 and JUnit 4 aren't completely incompatible with each other. So, for now, I'm using Assume from JUnit 4 (along with other stuff from JUnit 5).

import org.junit.Assume;


It's ugly, I don't like it (and I will be very grateful for another, cleaner, solution), but it's working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.