spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Support 'throw-away' context for a test class [SPR-13722]

Open spring-projects-issues opened this issue 9 years ago • 6 comments
trafficstars

Grzegorz Poznachowski opened SPR-13722 and commented

It would be nice to have an option for marking a single test class to get a fresh context and not use a cached context at all (i.e. using BeanFactoryPostProcessor for that test class).


Affects: 4.2.3

Reference URL: http://stackoverflow.com/questions/26931236/is-it-possble-to-reset-spring-tests-context-cache-before-a-test-suite-runs-not

Issue Links:

  • #16647 Support @ContextConfiguration at method level
  • #9309 Load dedicated child ApplicationContext for test instance in the TestContext framework
  • #12710 Limit size of context cache in the TestContext framework

1 votes, 3 watchers

spring-projects-issues avatar Nov 25 '15 11:11 spring-projects-issues

Sam Brannen commented

This issue is closely related to #16647.

spring-projects-issues avatar Nov 25 '15 15:11 spring-projects-issues

Sam Brannen commented

Dziesio,

What do you mean by the following?

i.e. using BeanFactoryPostProcessor for that test class

spring-projects-issues avatar Nov 25 '15 15:11 spring-projects-issues

Grzegorz Poznachowski commented

In some of my tests I'm using BeanFactoryPostProcessor to modify bean declarations. For such cases I would find throw-away context useful.

spring-projects-issues avatar Dec 07 '15 08:12 spring-projects-issues

We have a similar (small) issue where this would have been helpful as well.

denniseffing avatar Jan 25 '21 16:01 denniseffing

Did some one tried the @DirtiesContext annotation?

ian4hu avatar Jun 04 '21 08:06 ian4hu

Please note that I provided a DirtyContextBeforeAndAfterClassTestExecutionListener workaround on Stack Overflow.

sbrannen avatar Jan 04 '24 10:01 sbrannen