thomaskrieger / concurrent-junit Goto Github PK
View Code? Open in Web Editor NEWJUnit test runner to run concurrent unit tests
JUnit test runner to run concurrent unit tests
Hi,
I am using ConcurrentTestRunner. The code is running but it says 0 tests ran. I am using junit4.12. Any idea for this issue?
Hi, I started using your lib today and noticed that IntelliJ doesn't shows the tests results well after using ConcurrentTestRunner. I ran this
@RunWith(ConcurrentTestRunner.class)
public class TestingTests
{
@Test
public void thisShouldPass()
{
Assert.assertTrue(true);
}
@Test
public void thisShouldFail()
{
Assert.fail();
}
}
If I remove the @RunWith annotation for using the default runner, I get the expected behaviour:
Any ideas on this? I'm using Junit 4.12, Java 8 and IntelliJ 2016.2
Best regards
Luis.
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));
}
}
EOM
Since very many Java projects are built using maven, it would be useful to have this in a public maven repo too.
UpdateCarerDetailsResponse mockUpdateCarerDetailsResponse = new UpdateCarerDetailsResponse();
when(mockUpdateCarerService.updateIdentity(intPcehrHeader, null,validPassphrase))
.thenReturn(mockUpdateCarerDetailsResponse);
UpdateCarerDetailsResponse updateCarerDetailsResponse = updateCarerService.updateIdentity(intPcehrHeader, email, null);
I have added log statements before and after the above line of code in both the servlet and the test classes. The log statement after the above loc in the servlet class indicates that it is the same object that is used by all the 3 threads running the test method. On further debugging, i found that it is object created by the last thread that executed the test method that is used by the rest when executing the servlet method.
Please find below the log statements from the test and the servlet classes
[Thread-1] INFO XXX.UpdateCarerIdentityServletTest - 00000setting this value:java.io.PrintWriter@51645910 and response ::YYY._1.UpdateCarerDetailsResponse@3bf83cc for thread:Thread-1
[Thread-3] INFO XXX.UpdateCarerIdentityServletTest - 00000setting this value:java.io.PrintWriter@5f89131b and response ::YYY._1.UpdateCarerDetailsResponse@1641a275 for thread:Thread-3
[Thread-2] INFO XXX.UpdateCarerIdentityServletTest - 00000setting this value:java.io.PrintWriter@557d55ad and response ::YYY._1.UpdateCarerDetailsResponse@ 20f0767c for thread:Thread-2
[Thread-1] INFO XXX.UpdateCarerIdentityServlet - in actual 4444::for thread:Thread-1 updateCarerDetailsResponse:YYY._1.UpdateCarerDetailsResponse@20f0767c
[Thread-3] INFO XXX.UpdateCarerIdentityServlet - in actual 4444::for thread:Thread-3 updateCarerDetailsResponse:YYY._1.UpdateCarerDetailsResponse@20f0767c
[Thread-2] INFO XXX.UpdateCarerIdentityServlet - in actual 4444::for thread:Thread-2 updateCarerDetailsResponse:YYY._1.UpdateCarerDetailsResponse@20f0767c
Can someone help me understand why is a method variable being shared by threads?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.