Q:

Cache context in Spring test even if it failed to load

As mentioned in http://docs.spring.io/spring/docs/current/spring-framework-reference/html/testing.html#testcontext-ctx-management-caching, Spring will always tries to cache test contexts according to some generated key.
But, is there a way to cache a test context that failed to load? In other words -- if a test context failed to load, I do not want further tests to re-attempt loading it. In fact, they should just fail immediately with the same error that caused the initial context loading attempt to fail.
So, is there a way to do this in Spring? E.g., if I try to load a context whose "generated key" is the same as a previous one that failed to load, just fail immediately with the same error that the initial context loading attempt failed with/.

A:

No, as of Spring Framework 4.0.5 there is no mechanism for caching a failed ApplicationContext. 
If this is a feature you would like to see introduced in the Spring TestContext Framework, please create a JIRA issue for the "Spring Framework" project and "Test" component.
Regards,
Sam (author of the Spring TestContext Framework)

