Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-8503

Spring Test should not modify the application context under test

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 3.1 M2
    • Fix Version/s: None
    • Component/s: Test
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      When using @ContextConfiguration in a test @Autowired annotated fields get wired, even if <context:annotation-driven/> has not been specified.

      This is incorrect behaviour, as it means that a test can pass against a context configuration which when used in production will not behave that way.

      A better approach would be to load the specified configuration into one application context, and then use a child context for wiring the test fixture.

      The child context can then have the additional post processors, without polluting the application context under test.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sbrannen Sam Brannen
                Reporter:
                nealeu Neale Upstone
                Last updater:
                Trevor Marshall
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 years, 45 weeks, 1 day ago