java.lang.IllegalArgumentException: The test method of the supplied TestContext must not be null

Spring JIRA | Andrew Toolan | 8 months ago
  1. 0

    h1. Background: I am trying to run JUnit integration tests in parallel and repeatedly using the SpringClassRule and SpringMethodRule. To do this I am using a custom runner which executes the tests in parallel and using a repeat annotation to run each test repeatedly. However I have noticed that after multiple iterations the tests will begin failing. One test always appears to succeed. The resulting stack trace seems to indicate that the Application Context has been changed. The tests do not make use of the @DirtiesContext annotation however some of the errors received appear to complain about the test context being null. I am attaching a few examples of the stack traces, below is an example: {noformat} java.lang.IllegalArgumentException: The test method of the supplied TestContext must not be null at org.springframework.util.Assert.notNull(Assert.java:115) at org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener.beforeOrAfterTestMethod(AbstractDirtiesContextTestExecutionListener.java:95) at org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener.beforeTestMethod(DirtiesContextBeforeModesTestExecutionListener.java:95) at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:265) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.RunPrepareTestInstanceCallbacks.evaluate(RunPrepareTestInstanceCallbacks.java:64) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.springframework.test.context.junit4.statements.SpringFailOnTimeout.evaluate(SpringFailOnTimeout.java:87) at org.springframework.test.context.junit4.statements.ProfileValueChecker.evaluate(ProfileValueChecker.java:103) at com.ibm.toscana.util.junit.repeat.RunRepeatedly.evaluateStatement(RunRepeatedly.java:55) at com.ibm.toscana.util.junit.repeat.RunRepeatedly.evaluate(RunRepeatedly.java:34) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:232) at org.junit.experimental.theories.Theories$TheoryAnchor.runWithCompleteAssignment(Theories.java:218) at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:204) at com.ibm.toscana.util.junit.runner.ToscanaRunner$ParallelTheoryAnchor.runWithAssignment(ToscanaRunner.java:70) at org.junit.experimental.theories.Theories$TheoryAnchor.evaluate(Theories.java:187) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1397) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:300) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:168) {noformat} I have tried changing from the default Spring Repeat annotation to another implementation but I am seeing the same behavior. All tests are within the same test class. I was wondering if there was any reason why using SpringClassRule and SpringMethodRule in parallel might cause problems? I was hoping to try run the tests without the SpringMethodRule being applied as I do not need to leverage any of Springs Method level annotations but I noticed that there is an explicit dependency between them. I am using spring-boot version 1.3.2.RELEASE and JUnit 4.12.

    Spring JIRA | 8 months ago | Andrew Toolan
    java.lang.IllegalArgumentException: The test method of the supplied TestContext must not be null
  2. 0

    h1. Background: I am trying to run JUnit integration tests in parallel and repeatedly using the SpringClassRule and SpringMethodRule. To do this I am using a custom runner which executes the tests in parallel and using a repeat annotation to run each test repeatedly. However I have noticed that after multiple iterations the tests will begin failing. One test always appears to succeed. The resulting stack trace seems to indicate that the Application Context has been changed. The tests do not make use of the @DirtiesContext annotation however some of the errors received appear to complain about the test context being null. I am attaching a few examples of the stack traces, below is an example: {noformat} java.lang.IllegalArgumentException: The test method of the supplied TestContext must not be null at org.springframework.util.Assert.notNull(Assert.java:115) at org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener.beforeOrAfterTestMethod(AbstractDirtiesContextTestExecutionListener.java:95) at org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener.beforeTestMethod(DirtiesContextBeforeModesTestExecutionListener.java:95) at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:265) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.RunPrepareTestInstanceCallbacks.evaluate(RunPrepareTestInstanceCallbacks.java:64) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.springframework.test.context.junit4.statements.SpringFailOnTimeout.evaluate(SpringFailOnTimeout.java:87) at org.springframework.test.context.junit4.statements.ProfileValueChecker.evaluate(ProfileValueChecker.java:103) at com.ibm.toscana.util.junit.repeat.RunRepeatedly.evaluateStatement(RunRepeatedly.java:55) at com.ibm.toscana.util.junit.repeat.RunRepeatedly.evaluate(RunRepeatedly.java:34) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:232) at org.junit.experimental.theories.Theories$TheoryAnchor.runWithCompleteAssignment(Theories.java:218) at org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:204) at com.ibm.toscana.util.junit.runner.ToscanaRunner$ParallelTheoryAnchor.runWithAssignment(ToscanaRunner.java:70) at org.junit.experimental.theories.Theories$TheoryAnchor.evaluate(Theories.java:187) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1397) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:300) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:168) {noformat} I have tried changing from the default Spring Repeat annotation to another implementation but I am seeing the same behavior. All tests are within the same test class. I was wondering if there was any reason why using SpringClassRule and SpringMethodRule in parallel might cause problems? I was hoping to try run the tests without the SpringMethodRule being applied as I do not need to leverage any of Springs Method level annotations but I noticed that there is an explicit dependency between them. I am using spring-boot version 1.3.2.RELEASE and JUnit 4.12.

    Spring JIRA | 8 months ago | Andrew Toolan
    java.lang.IllegalArgumentException: The test method of the supplied TestContext must not be null
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    JMS message listener error

    Stack Overflow | 8 months ago | user3649231
    org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.apache.activemq.ActiveMQConnectionFactory kr.ac.jbnu.sql.rded.config.AppConfig.amqFactory; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'amqConnectionFactory' defined in class path resource [kr/ac/jbnu/sql/rded/config/AppConfig.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [javax.jms.ConnectionFactory]: Error creating bean with name 'cachingConnectionFactory' defined in class path resource [kr/ac/jbnu/sql/rded/config/AppConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.jms.connection.CachingConnectionFactory]: Circular reference involving containing bean 'appConfig' - consider declaring the factory method as static for independence from its containing instance. Factory method 'cachingConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Target ConnectionFactory must not be null; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cachingConnectionFactory' defined in class path resource [kr/ac/jbnu/sql/rded/config/AppConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.jms.connection.CachingConnectionFactory]: Circular reference involving containing bean 'appConfig' - consider declaring the factory method as static for independence from its containing instance. Factory method 'cachingConnectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: Target ConnectionFactory must not be null
  5. 0

    RemoteFileTemplate throws 'remoteDirectoryExpression' is required when using SftpOutboundGateway

    Stack Overflow | 1 year ago | Jimmersons
    java.lang.IllegalArgumentException: 'remoteDirectoryExpression' is required

  1. batwalrus76 4 times, last 2 weeks ago
  2. serious2monkeys 1 times, last 2 weeks ago
  3. tvrmsmith 1 times, last 3 weeks ago
  4. fima 1 times, last 2 months ago
  5. dafman 2 times, last 2 months ago
8 more registered users
87 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalArgumentException

    The test method of the supplied TestContext must not be null

    at org.springframework.util.Assert.notNull()
  2. Spring Core
    Assert.notNull
    1. org.springframework.util.Assert.notNull(Assert.java:115)
    1 frame
  3. Spring TestContext
    ProfileValueChecker.evaluate
    1. org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener.beforeOrAfterTestMethod(AbstractDirtiesContextTestExecutionListener.java:95)
    2. org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener.beforeTestMethod(DirtiesContextBeforeModesTestExecutionListener.java:95)
    3. org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:265)
    4. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    5. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    6. org.springframework.test.context.junit4.statements.RunPrepareTestInstanceCallbacks.evaluate(RunPrepareTestInstanceCallbacks.java:64)
    7. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    8. org.springframework.test.context.junit4.statements.SpringFailOnTimeout.evaluate(SpringFailOnTimeout.java:87)
    9. org.springframework.test.context.junit4.statements.ProfileValueChecker.evaluate(ProfileValueChecker.java:103)
    9 frames
  4. com.ibm.toscana
    RunRepeatedly.evaluate
    1. com.ibm.toscana.util.junit.repeat.RunRepeatedly.evaluateStatement(RunRepeatedly.java:55)
    2. com.ibm.toscana.util.junit.repeat.RunRepeatedly.evaluate(RunRepeatedly.java:34)
    2 frames
  5. JUnit
    Theories$TheoryAnchor.runWithAssignment
    1. org.junit.rules.RunRules.evaluate(RunRules.java:20)
    2. org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:232)
    3. org.junit.experimental.theories.Theories$TheoryAnchor.runWithCompleteAssignment(Theories.java:218)
    4. org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:204)
    4 frames
  6. com.ibm.toscana
    ToscanaRunner$ParallelTheoryAnchor.runWithAssignment
    1. com.ibm.toscana.util.junit.runner.ToscanaRunner$ParallelTheoryAnchor.runWithAssignment(ToscanaRunner.java:70)
    1 frame
  7. JUnit
    ParentRunner$3.run
    1. org.junit.experimental.theories.Theories$TheoryAnchor.evaluate(Theories.java:187)
    2. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    3. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    4. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    5. org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    5 frames
  8. Java RT
    ForkJoinWorkerThread.run
    1. java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1397)
    2. java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:300)
    3. java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067)
    4. java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703)
    5. java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:168)
    5 frames