Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I have a bunch of "tests vintages" that need to run in parallel to optimize the execution time.
Our environment is a little complicated. The simplest solution is to use the junit console. but some test class really needs to be executed in a forked jvm.

It's possible to run test classes in forked jvm via ant junit and maven surefire but didn't found a way via junit console standalone.
Is there a way to run the tests in a separate JVM using the console ?

image
sources

You must be logged in to vote

Replies: 3 comments · 3 replies

Comment options

You can run a separate ConsoleLauncher process with a single --select-class for each test class.

You must be logged in to vote
2 replies
@ggjulio
Comment options

Ty for your hint!

That's already what I do, but some code invoked in the testsclass may call exit.
In that case the launcher won't get a chance to finish it's work, write reports and exit properly.

Whereas on ant, it's not an issue when using fork=true to execute the testclass code in separate jvm process.

I guess I'll have to use ant then ?

@marcphilipp
Comment options

Yes, I think that's the only viable option as of now. Java's SecurityManager mechanism is deprecated and there's no new API, yet. Implementing forking in the ConsoleLauncher would be quite involved as we would have to transfer test events from the forked JVM back to the ConsoleLauncher's JVM for reporting etc.

Comment options

I wonder, if JUnit's Console Launcher could register a shutdown hook via Runtime::addShutdownHook and perform "manouvers of the final moment", such as to close contexts, write reports, free resources, ... and be good? 🤔

You must be logged in to vote
1 reply
@marcphilipp
Comment options

It would probably improve the experience somewhat but it would have to make sure to synthesize finish events for tests that have been started etc. in order to produce non-broken reports. It's certainly doable but would be quite involved as well.

Comment options

If I understood https://bugs.openjdk.org/browse/JDK-8199704 correctly, there won't be a new API for catching System::exit

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.