Hi Emond, This section of code is executed for the forkCount > 1 https://github.com/apache/maven-surefire/blob/master/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java#L194-L202 The above part runs if the forkCount is 1.
Do you think that using the session together with the try-with-resource in the selected section of code makes the trick? Pls check it your local in your local branch and your project. T On Fri, Sep 10, 2021 at 11:33 PM Emond Papegaaij <[email protected]> wrote: > Hi Tibor, > > That's what I implemented, although I couldn't use the fancy try, because > of the way the code is structured. The LauncherSession is started by > LazyLauncher. This will allow registering a listener for opening and > closing the session, given a place for pre and post fixtures. > > Best regards, > Emond > > Op vr 10 sep. 2021 23:00 schreef Tibor Digana <[email protected]>: > > > Hi Emond, > > > > Are you looking for this? > > > > > https://github.com/junit-team/junit5/blob/main/documentation/src/test/java/example/UsingTheLauncherDemo.java#L86-L96 > > > > On Fri, Sep 10, 2021 at 10:49 PM Emond Papegaaij < > > [email protected]> > > wrote: > > > > > On Fri, Sep 10, 2021 at 9:15 PM Emond Papegaaij < > > [email protected] > > > > > > > wrote: > > > > > > > On Fri, Sep 10, 2021 at 8:41 PM Christian Stein <[email protected]> > > > > wrote: > > > > > > > >> On Fri, Sep 10, 2021 at 8:27 PM Emond Papegaaij < > > > >> [email protected]> > > > >> wrote: > > > >> > > > >> For now, I think the LauncherSession is the best way to at least > > provide > > > >> > some hooks for pre and post fixtures. It shouldn't be too hard to > > get > > > >> this > > > >> > in the current code base with backwards compatibility for JUnit > > > Platform > > > >> > 1.7 and older. I'll see if I can create a pull request for this > > > >> somewhere > > > >> > next week. > > > >> > > > > >> > > > >> Before investing too much energy into a PR, please start a > discussion > > or > > > >> open a feature request first - chances are that what you seek to > > achieve > > > >> is already possible, or somebody else has filed a similar request. > > > > > > > > > > > > You mean at JUnit? I'm pretty sure that it's currently not possible. > > I've > > > > been stepping through that code for quite some time now, and the > whole > > > > TestPlan construction is very static. There doesn't seem to be an > open > > > > request for this at the moment. > > > > > > > > The API for a LauncherSession is very simple and I think it's a good > > idea > > > > to use it anyway. The hardest part will be to only start the session > > when > > > > using 1.8 or higher. > > > > > > > > > > That was easier than I thought. I've already got a working POC at > > > > > > > > > https://github.com/topicusonderwijs/maven-surefire/commit/b112130170c244846d5e35353a4c90afaf42aff1 > > > . The only problems at the moment are that some tests fail because a > > > TestPlan is immutable in 1.8, the main process creates a > LauncherSession > > > that is never closed and I screwed up the formatting in some places. > With > > > this change, a LauncherSession is created when JUnit Platform 1.8 is > > used. > > > This session is closed when all tests have been executed. When running > on > > > 1.7 or lower, it falls back to the old behavior. I've verified that > only > > > one LauncherSession is created per fork when running with forkCount > > 1. > > > > > > Best regards, > > > Emond > > > > > >
