Execution of the following test even without EclEmma
package io.reactivex.rxjava3.core;
import org.junit.Test;
public class ExampleTest extends RxJavaTest {
@Test
public void test() {
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
System.err.println("hook executed");
}
}));
}
}
Won't print anything, whereas execution of the same test without "extends RxJavaTest" will print "hook executed".
The same test will also print "hook executed" if you remove "globalTimeout" defined in "RJavaTest".
From the above IMO clear that the issue is not in EclEmma.
Furthermore, problem with execution of JVM shutdown hooks
in presence of org.junit.rules.Timeout from JUnit 4.13 can be demonstrated
without Eclipse
using following "build.gradle"
apply plugin: 'java'
repositories {
mavenCentral()
}
test {
testLogging.showStandardStreams = true
}
dependencies {
testCompile 'junit:junit:4.13'
}
and following "src/test/java/Example.java"
import org.junit.Test;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
import java.util.concurrent.TimeUnit;
public class ExampleTest {
@Rule
public Timeout globalTimeout = new Timeout(5, TimeUnit.MINUTES);
@Test
public final void test() {
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
System.err.println("hook executed");
}
}));
}
}
And since the problem goes away in all the above cases after downgrade to JUnit 4.12,
then IMO it is caused by changes in JUnit 4.13.
Regards,
Evgeny