Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a @NotThreadSafe annotation #141

Closed
arcuri82 opened this issue Jan 28, 2016 · 4 comments
Closed

Introduce a @NotThreadSafe annotation #141

arcuri82 opened this issue Jan 28, 2016 · 4 comments

Comments

@arcuri82
Copy link
Contributor

Feature request:

To speed up testing, one would like to run unit tests in parallel on the same JVM.
This is already possible for example in the Maven Surefire plugin.
However, in some cases you cannot run some of the unit tests in parallel.
An example is when more than one test does manipulate the same static state, eg a cache.
It would be good to be able to have a tag to specify that a specific test (or test class) should never be run in parallel on the same JVM.
It would be then the responsibility of the runner (eg Surefire/Failsafe plugins) to honor such constraint.

A further annotation (or an option in the above one) could be used to tag a test to never run in parallel, not even if in a different spawn JVM. This might be for example useful if a set of tests are manipulating a same external resource (eg writing/reading a file). I personally never encountered such case, but I guess it could happen.

@Tibor17
Copy link

Tibor17 commented Feb 13, 2016

Use JCIP annotations as we do in Surefire few years.
As @arcuri82 mentioned, we use it in Surefire and here is our documentation
https://maven.apache.org/surefire/maven-failsafe-plugin/examples/fork-options-and-parallel-execution.html#Parallel_Test_Execution_and_Single_Thread_Execution

@djangofan
Copy link

djangofan commented Jul 12, 2016

WHEN forking test by class, my utopian dream is that each fork isolates the test in a way such that exceptions wont interrupt the test suite, but only fail the individual test-thread. Thats a problem I have with TestNG running via Surefire. This could be where JUnit might be able to exceed TestNG.

@marcphilipp marcphilipp modified the milestones: 5.1+ Backlog, 5.0 M5 Dec 22, 2016
@marcphilipp marcphilipp modified the milestones: 5.0 M5, 5.0 M6 May 6, 2017
@sbrannen sbrannen modified the milestones: 5.0 M6, 5.0 RC1 Jul 3, 2017
@marcphilipp marcphilipp modified the milestones: 5.0 RC1, 5.1 Backlog Jul 30, 2017
@marcphilipp
Copy link
Member

Related issue: #60.

@marcphilipp
Copy link
Member

This can be done since 5.3 using @Execution(SAME_THREAD).

@marcphilipp marcphilipp removed this from the 5.x Backlog milestone Dec 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants