Skip to content

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

Closed
@spring-projects-issues

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:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions