title: Why is my Spring JUnit Test Rule not running?
body: <p>I've been struggling to find an obvious solution to why the linked code will not run JUnit TestRules. </p>
  
  <p>I've created a <a href="https://github.com/johndeverall/testcases/tree/master/JUnitTestRulesInSerenity/TestRuleSuccessCase" rel="nofollow">success case</a> where TestRules execute, and a <a href="https://github.com/johndeverall/testcases/tree/master/JUnitTestRulesInSerenity/TestRuleFailureCase" rel="nofollow">failure case</a> that shows a situation where TestRules fail. </p>
  
  <p>Is anybody able to see why the TestRules are not being picked up? It's not just Spring's TestRule not being picked up. It seems to be all TestRules, as demonstrated by MyTestRule.java in the source code.</p>
  
  <p>Running <code>mvn clean install</code> on the success case, will see all tests passing. However running <code>mvn clean install</code> on the failure case will produce the following failure:</p>
  
  <pre><code>    Tests run: 13, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.9 sec &lt;&lt;&lt; FAILURE! - in net.serenitybdd.demos.acceptance.CalculateResults
  net.serenitybdd.demos.acceptance.CalculateResults  Time elapsed: 1.454 sec  &lt;&lt;&lt; FAILURE!
  java.lang.AssertionError: expected:&lt;3&gt; but was:&lt;1&gt;
          at org.junit.Assert.fail(Assert.java:88)
          at org.junit.Assert.failNotEquals(Assert.java:743)
          at org.junit.Assert.assertEquals(Assert.java:118)
          at org.junit.Assert.assertEquals(Assert.java:555)
          at org.junit.Assert.assertEquals(Assert.java:542)
          at net.serenitybdd.demos.acceptance.CalculateResults.test(CalculateResults.java:60)
  
  
  Results :
  
  Failed tests:
    CalculateResults.test:60 expected:&lt;3&gt; but was:&lt;1&gt;
  
  Tests run: 13, Failures: 1, Errors: 0, Skipped: 0
  </code></pre>
  
  <p>This is a result of Spring's <a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/test/context/junit4/rules/SpringMethodRule.html" rel="nofollow">SpringMethodRule</a> not being picked up, which can be seen in the test class <code>net.serenitybdd.demos.acceptance.CalculateResults</code>.</p>
  
  <p>Does anyone have any ideas? </p>