Skip to content

Support @EnabledIf and @DisabledIf without loading ApplicationContext [SPR-14649] #19215

Closed
@spring-projects-issues

Description

@spring-projects-issues

Sam Brannen opened SPR-14649 and commented

Status Quo

The recently added support for @EnabledIf and @DisabledIf allows for conditional test execution in JUnit Jupiter via SpEL expressions and property look-ups in the Spring Environment.

This functionality is extremely powerful; however, there is also a very large drawback with the current implementation. Namely, the test's ApplicationContext is always eagerly loaded, even if the ApplicationContext will never be used by a test.

Deliverables

  1. Introduce a boolean flag in @EnabledIf and @DisabledIf to control whether the test's ApplicationContext should be eagerly loaded.
    • set the default for the flag to false so that users have to explicitly think about the consequences.
  2. Introduce code for evaluating the following when the test's ApplicationContext is not available:
    • property placeholders for system properties and environment variables
    • SpEL expressions that do not access beans from the ApplicationContext

Affects: 5.0 M2

Issue Links:

Referenced from: commits 5c9350b

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions