Skip to content

Support test annotations on interfaces [SPR-14184] #18755

Closed

Description

@spring-projects-issues

Sam Brannen opened SPR-14184 and commented

Status Quo

Prior to Java 8 it never really made much sense to author integration tests using interfaces. Consequently, the Spring TestContext Framework has never supported finding test-related annotations on interfaces in its search algorithms.

However, Java 8's support for interface default methods introduces new testing use cases for which it makes sense to declare test configuration (e.g., @ContextConfiguration, etc.) on an interface containing default methods instead of on an abstract base class.

Deliverables

For each of the following annotations, implement and test support for declaration on test interfaces.

  1. @ActiveProfiles
    • see ActiveProfilesInterfaceTests
  2. @BootstrapWith
    • see BootstrapWithInterfaceTests
  3. @ContextConfiguration
    • see ContextConfigurationInterfaceTests
  4. @ContextHierarchy
    • see ContextHierarchyInterfaceTests
  5. @WebAppConfiguration
    • see WebAppConfigurationInterfaceTests
  6. @DirtiesContext
    • see DirtiesContextInterfaceTests
  7. @TestExecutionListeners
    • see customListenersDeclaredOnInterface() in TestExecutionListenersTests
  8. @TestPropertySource
    • see TestPropertySourceInterfaceTests
  9. @Sql and @SqlGroup
  10. @SqlConfig
    • see SqlConfigInterfaceTests
  11. @Commit
    • see TransactionalTestExecutionListenerTests
  12. @Rollback
    • see TransactionalTestExecutionListenerTests
  13. @IfProfileValue
    • see DisabledAnnotatedSingleValueOnTestInterface in ProfileValueUtilsTests
  14. @ProfileValueSourceConfiguration
    • see EnabledWithCustomProfileValueSourceOnTestInterface in ProfileValueUtilsTests

Issue Links:

Activity

  1. spring-projects-issues commented on May 5, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Completed in GitHub commit a1a8767.

  2. added
    in: test
    type: enhancement
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: testtype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions