Giter Club home page Giter Club logo

concurrent-junit's People

Contributors

thomaskrieger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

concurrent-junit's Issues

ConcurrentTestRunner not notifying passed tests on intellij

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();
	}
}

And got this:
Current behaviour

If I remove the @RunWith annotation for using the default runner, I get the expected behaviour:

Expected behaviour

Any ideas on this? I'm using Junit 4.12, Java 8 and IntelliJ 2016.2

Best regards
Luis.

ConcurrentTestRunner does not work with ErrorCollector rule

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));
  }

}

Maven dependency?

Since very many Java projects are built using maven, it would be useful to have this in a public maven repo too.

When() then return always returns the same object to all threads

I am using ConcurrentTestRunner with Powermock, but there is an inconsistency in the test results. On further debugging i realised that all the threads running the test method are using the same object that was created by the last thread when executing the following loc.
Test class loc

UpdateCarerDetailsResponse mockUpdateCarerDetailsResponse = new UpdateCarerDetailsResponse();
when(mockUpdateCarerService.updateIdentity(intPcehrHeader, null,validPassphrase))
.thenReturn(mockUpdateCarerDetailsResponse);

Actual Servlet class

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.