Unfortunately this isn't something that can be fixed in
JUnitBenchmarks. The rule order (and method order returned from java
reflection, for that matter) is not guaranteed. JUnit's MethodRule and
TestRule nesting is different so indeed there was a change-of-behavior
between 0.4.0 and further versions.
If your test case requires a setup use a trick and set up an explicit
rule chain that calls the benchmarking rule as the *last* rule. Then
you can inject an additional rule that will call your before and after
hooks once. This is shown here, for example:
https://github.com/carrotsearch/junit-benchmarks/blob/master/src/test/java/com/carrotsearch/junitbenchmarks/TestJUnitHooksWorkAround.java#L21
Dawid