<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=alef.arendsen" rel="nofollow">Alef Arendsen</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-4061?redirect=false" rel="nofollow">SPR-4061</a></strong> and commented</p>
<p dir="auto">The following code in SpringJUnit4Runner swallows the exception thrown by context creation (if any) instead of throwing it. This means test execution is continuing, while it should fail:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@Override
protected Object createTest() throws Exception {
	final Object testInstance = super.createTest();
	try {
		getTestContextManager().prepareTestInstance(testInstance);
	}
	catch (Throwable t) {"><pre class="notranslate"><code class="notranslate">@Override
protected Object createTest() throws Exception {
	final Object testInstance = super.createTest();
	try {
		getTestContextManager().prepareTestInstance(testInstance);
	}
	catch (Throwable t) {
</code></pre></div>
<p dir="auto">// should throw exception instead of only creating one<br>
new Exception(t);<br>
}<br>
return testInstance;<br>
}</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5 RC1</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=springboy" rel="nofollow">Rick Evans</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-4025?redirect=false" rel="nofollow">SPR-4025</a></strong> and commented</p>
<p dir="auto">Hola campers!</p>
<p dir="auto">SpringJUnit4ClassRunner, createTest() contains this code (sans comment):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="final Object testInstance = super.createTest();
try {
     getTestContextManager().prepareTestInstance(testInstance);
}
catch (Throwable t) {
     new Exception(t); // &lt;--------------- eh?
}
return testInstance;"><pre class="notranslate"><code class="notranslate">final Object testInstance = super.createTest();
try {
     getTestContextManager().prepareTestInstance(testInstance);
}
catch (Throwable t) {
     new Exception(t); // &lt;--------------- eh?
}
return testInstance;
</code></pre></div>
<p dir="auto">The line 'new Exception(t)' needs to be 'throw new Exception(t);' (At least I think it does.)</p>
<p dir="auto">Cheers<br>
Rick</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5 RC1</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/13055/SpringJUnit4ClassRunnerTests.java" rel="nofollow">SpringJUnit4ClassRunnerTests.java</a> (<em>933 bytes</em>)</li>
</ul>