ThomasKrieger / concurrent-junit

JUnit test runner to run concurrent unit tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ConcurrentTestRunner does not work with ErrorCollector rule

david-m-s opened this issue · comments

When one test using ErrorCollector fails, all the following tests report the same failure. I have created a small snippet to demonstrate this.
You can play with the test names to affect ordering and change the runner.

Runner Test order Expected Actual
default failing 1st fail, pass fail, pass
default failing last pass, fail fail, pass
concurrent failing 1st fail, pass fail, 🔴fail
concurrent failing last pass, fail pass, fail
import com.anarsoft.vmlens.concurrent.junit.ConcurrentTestRunner;
import org.hamcrest.Matchers;
import org.junit.FixMethodOrder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ErrorCollector;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import static org.junit.Assert.assertTrue;

// Fixed test order. Rename test0 to test_ to see the change
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
// Change to default runner and the result is the expected in any test order.
@RunWith(ConcurrentTestRunner.class)
public class TestErrorCollector {

  @Rule
  public ErrorCollector errors = new ErrorCollector();

  @Test
  public void test1() {
    assertTrue(true);
  }

  @Test
  public void test0() {
    errors.checkThat(1, Matchers.equalTo(2));
  }

}