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

Provide TestContext support for @Configuration classes

    XMLWordPrintable

Details

    • 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

              sbrannen Sam Brannen
              cbeams Chris Beams
              Spring Issues Spring Issues
              Votes:
              37 Vote for this issue
              Watchers:
              30 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                3 years, 46 weeks, 4 days ago