junit5 icon indicating copy to clipboard operation
junit5 copied to clipboard

Document concurrency considerations for TestExecutionListener implementations

Open jaikiran opened this issue 4 years ago • 5 comments

I've been looking at some documentations to see if there is any thread safety semantics to consider when implementing a org.junit.platform.launcher.TestExecutionListener. I haven't found any, so asking here.

More specifically, is there ever a case where the same instance of TestExecutionListener could get invoked by multiple threads (simultaneously), such that these implementations need to handle any thread safety issues? If so, is it only for certain methods or do all methods on that interface's implementation need to take into account this aspect? For example, in theory, I wouldn't expect more than one thread invoking the testPlanExecutionFinished method.

jaikiran avatar Jan 24 '21 05:01 jaikiran

Good point, we should document that. testPlanExecutionStarted and testPlanExecutionFinished are always called from the same thread and it's safe to assume there's at most one TestPlan at a time (in theory, someone could call the Launcher concurrently but AFAIK no tool does that). All other method could be called from different threads concurrently in case one or multiple test engines execute tests in parallel.

marcphilipp avatar Jan 24 '21 10:01 marcphilipp

@marcphilipp, thank you. That answer helps me decide how to go about one of the implementations in Apache Ant.

jaikiran avatar Jan 25 '21 04:01 jaikiran

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. Thank you for your contribution.

stale[bot] avatar Jun 21 '22 00:06 stale[bot]

This issue has been automatically closed due to inactivity. If you have a good use case for this feature, please feel free to reopen the issue.

stale[bot] avatar Jul 12 '22 23:07 stale[bot]

The proposed documentation change sounds useful to me, so I wonder if this issue should be re-opened?

jbduncan avatar Jul 13 '22 10:07 jbduncan

I'd like to give this one a try. :) Is updating the Javadoc on org.junit.platform.launcher.TestExecutionListener enough, or is there another guide to update as well?

edysli avatar Oct 04 '22 20:10 edysli