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

Provide TestContext support for @Configuration classes

    Details

    • Last commented by a User:
      true

      Description

      Currently, JavaConfig integrates with the TestContext framework via its ContextLoader implementation, JavaConfigContextLoader:

      @RunWith(SpringJUnit4ClassRunner.class)
      @ContextConfiguration(locations="com.bank.TransferAppConfig",
                            loader=JavaConfigContextLoader.class)
      public class TransferServiceTests {
          // @Test methods ...
      }
      

      This integration works well enough but is not refactoring-friendly due to the requirement that @ContextConfiguration imposes that locations must be a String[]. It forces the fully-qualified class name to be expressed as a string, when it would clearly be superior to be able to pass it around by Class literal.

      Implementing this change would require a change to core, either by adding an attribute to @ContextConfiguration that takes a Class[] (not likely), or otherwise devising a way of proving a customized annotation (e.g., @JavaConfigContextConfiguration).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sbrannen Sam Brannen
                Reporter:
                cbeams Chris Beams
                Last updater:
                Trevor Marshall
              • Votes:
                37 Vote for this issue
                Watchers:
                30 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 years, 45 weeks, 2 days ago