Skip to content

no-op behavior for Junit classes [SPR-3264] #7949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Mar 14, 2007 · 1 comment
Closed

no-op behavior for Junit classes [SPR-3264] #7949

spring-projects-issues opened this issue Mar 14, 2007 · 1 comment
Assignees
Labels
in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 14, 2007

Costin Leau opened SPR-3264 and commented

If the current test classes provided in Spring have to be reused (as we do in Spring/OSGi), there are a few bumps which make extension hard.

One particular problem occurs in AbstractSingleSpringContextTests and AbstractDependencyInjectionSpringContextTests. The first class always expects an application context to be created even if no files/locations are specified which can lead to NPE problems or force an appCtx to be instantiated even if not needed.
Even if the first problem can be overcome, the second test will try to apply auto-injection; this can be disabled but it has to be done manually inside the onSetUp...

Basicaly, it would be nice to have a no-op behavior; if nothing is supplied then the functionality inside the test is not applied. Again this makes sense, if the test is used as a base class. Another solution would be to move some of the functionality outside the test class so new hierachies don't have to extend this one. However, this doesn't add a lot of benefits since in most cases, the functionality has to be applied on the test itself.


Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Sam Brannen commented

Hi Costin,

I have added your requested no-op behavior to the JUnit 3.8 legacy
testing support.

One particular problem occurs in AbstractSingleSpringContextTests and
AbstractDependencyInjectionSpringContextTests. The first class always
expects an application context to be created even if no files/locations
are specified which can lead to NPE problems or force an appCtx to be
instantiated even if not needed.

AbstractSpringContextTests: getContext(Object) now checks if the context
key is 'empty' before attempting to retrieve or load an ApplicationContext.

Even if the first problem can be overcome, the second test will try to
apply auto-injection; this can be disabled but it has to be done
manually inside the onSetUp...

AbstractDependencyInjectionSpringContextTests: prepareTestInstance() will
only call injectDependencies() if the ApplicationContext has actually been
configured.

Note that the new Spring TestContext Framework already supports similar
"no-op behavior" based on whether or not @ContextConfiguration is
present on the test class, etc. Thus if you are not restricted to using the
JUnit 3.8 legacy support, we recommend that you write all new integration
tests with the TestContext framework.

Regards,

Sam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants