Spring Framework
  1. Spring Framework
  2. SPR-7996

Improve documentation of the context caching mechanism in the TestContext framework

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: 2.5.6, 3.0.5
    • Fix Version/s: 3.1 RC2
    • Component/s: [Documentation], Test
    • Labels:
      None

      Description

      Overview

      Unit/integration test execution libraries can sometimes be configured to execute tests in a forked manner (see surefire's forkMode configuration). When tests are run in a forked mode, in-memory @ContextConfiguration caching no longer applies, and the context will be reloaded for every forked process.

      The Spring reference manual merely states that @ContextConfiguration is cached and does not go into much detail beyond that. I think it would be good to specify that the cache is in-memory and thus will only be usable for tests which run within the same JVM process / class space. Perhaps a Spring note (the ones with the little leaf icon and block quote styling) would be good to call this out in the Testing chapter.

      To Document

      • cache key generation, including a discussion of the algorithm in MergedContextConfiguration
      • cache scope and implications in a test suite, including a discussion of forking

        Issue Links

          Activity

          Hide
          Caleb Jones added a comment -

          Link to surefire's forkMode had a trailing quotation mark which invalidates the URL's anchor.

          Correct URL is:
          http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#forkMode

          Show
          Caleb Jones added a comment - Link to surefire's forkMode had a trailing quotation mark which invalidates the URL's anchor. Correct URL is: http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#forkMode
          Hide
          Caleb Jones added a comment -

          May also be good to note that for a fairly sizable number of test classes using @ContextConfiguration, forking each in its own process will result in very long test execution times since (again) the context must be re-created for each test class.

          See forum comments for more details.

          Show
          Caleb Jones added a comment - May also be good to note that for a fairly sizable number of test classes using @ContextConfiguration, forking each in its own process will result in very long test execution times since (again) the context must be re-created for each test class. See forum comments for more details.
          Hide
          Sam Brannen added a comment -

          Improved documentation of the context caching mechanism in the TestContext framework:

          • now discussing cache key generation and uniqueness
          • now discussing cache scope, test suites, and forking
          Show
          Sam Brannen added a comment - Improved documentation of the context caching mechanism in the TestContext framework: now discussing cache key generation and uniqueness now discussing cache scope, test suites, and forking

            People

            • Assignee:
              Sam Brannen
              Reporter:
              Caleb Jones
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 21 weeks ago