TearDown Level coarser than Trial

Aleksey Shipilev ashipile at redhat.com
Fri Jan 3 14:49:58 UTC 2020


(going through my accumulated mail)

On 12/11/19 11:31 AM, Håvard Ottestad wrote:
> Is there some intuitive way that I’m overlooking to get this working the way I want? Or is it
> just not possible due to the isolation between trials?
There is no such level. You guessed right: it is because of the isolation between trials.

There is also a dependency: setup/teardown manage @State object state, and setup/teardowns are
always called on the same object. Since @State objects are isolated between trials,
@TearDown(Level.Class) would be really awkward: @Setup would be called on one object, and @TearDown
on another. You would not be able to pass any data between these via the "normal" sharing.

I guess there is a room for some separate facility, like JUnit's @BeforeClass/@AfterClass.

-Aleksey



More information about the jmh-dev mailing list