Spring Framework
  1. Spring Framework
  2. SPR-6050

Provide mechanism for disabling automatic annotation-driven autowiring in tests

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.5.6
    • Fix Version/s: None
    • Component/s: Test
    • Labels:
      None

      Description

      In the Spring TestContext Framework (i.e., specifically in AbstractGenericContextLoader), annotation-driven autowiring is automatically enabled. In other words, all ApplicationContexts created by subclasses of AbstractGenericContextLoader (e.g., GenericXmlContextLoader) are automatically configured to process annotations.

      If you explicitly wish that annotation processing not be enabled for the configuration files you specify – for example, if some of the beans are annotated with @Autowired, etc. but you do not want those beans to be autowired – you are at a loss: there is currently no way to disable this.

      As indirectly suggested in the forum, it would be nice if Spring provided a mechanism for disabling automatic annotation-driven autowiring in tests.

        Issue Links

          Activity

          Hide
          Sam Brannen added a comment -

          This issue is essentially a duplicate of SPR-4632 in some respects, but the difference is that SPR-4632 recommends to have annotation-driven dependency injection enabled only for the test instance; whereas, this issue proposes to provide a mechanism to disable this functionality on a per-test-instance basis.

          Thus I'm leaving both issues open until a decision has been made as to what route to take (if either).

          Show
          Sam Brannen added a comment - This issue is essentially a duplicate of SPR-4632 in some respects, but the difference is that SPR-4632 recommends to have annotation-driven dependency injection enabled only for the test instance; whereas, this issue proposes to provide a mechanism to disable this functionality on a per-test-instance basis. Thus I'm leaving both issues open until a decision has been made as to what route to take (if either).
          Hide
          Sam Brannen added a comment -

          Resolving this issue as "Won't Fix" since we have opted to implement the "child context" solution proposed in SPR-4632 instead.

          Show
          Sam Brannen added a comment - Resolving this issue as " Won't Fix " since we have opted to implement the "child context" solution proposed in SPR-4632 instead.

            People

            • Assignee:
              Sam Brannen
              Reporter:
              Sam Brannen
              Last updater:
              Sam Brannen
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                10 weeks, 2 days ago