JUnit 5 Fundamentals
Conditional Test Execution Pairs: @EnabledIfSystemProperty & @DisabledIfSystemProperty
Autoplay
Up next
Previous
About
Overview
In this lesson, we'll explore how Java system properties can drive the execution of tests in JUnit Jupiter. We provide a custom system property to the Run Configuration in our IDE, and verify that Jupiter will enable all tests annotated with @EnabledIfSystemProperty
, given that the property's value matches the expectation inside the annotation. Conversely, other tests can be disabled using the same process, with @DisabledIfSystemProperty
. We'll come to appreciate the verbose nature of the framework's logging once more, because the TestEngine
will print statements to the console about the different reasons it chose to execute or skip a test.
Summary
- Configure Java system properties to drive test execution
@EnabledIfSystemProperty
checks the value of a property against a regular expression; only in case of a match, the element is executed@DisabledIfSystemProperty
checks the value of a property against a regular expression; in case of a match, the element is never executed- If a property doesn't exist at all,
@DisabledIfSystemProperty
methods are always executed
Instructor
Links
Comments
Lessons in JUnit 5 Fundamentals
1. Understand the Core Components of JUnit 5
02:11
2. Set up your Java Project for JUnit 5

01:25
3. Set up your Android Project for JUnit 5

01:42
4. The first @Test

02:06
5. Lifecycle with @BeforeEach & @AfterEach

01:09
6. Lifecycle with @BeforeAll & @AfterAll

Pro
01:10
7. Using 1 Instance per Method with @TestInstance

Pro
01:12
8. Using 1 Instance per Class with @TestInstance

Pro
02:01
9. Taking advantage of @TestInstance(PER_CLASS) in Kotlin

Pro
01:25
10. Bearable Test Method Names with @DisplayName

Pro
02:19
11. Checking for equality with assertEquals() & Friends

Pro
02:53
12. Using assertTrue() & assertFalse()

Pro
00:51
13. Asserting null

Pro
00:38
14. Testing Exceptions with assertThrows()

Pro
01:10
15. Composing Assertions with assertAll()

Pro
02:00
16. Avoiding failure with Assumptions

Pro
01:33
17. Ignoring Tests with @Disabled

Pro
01:31
18. Conditional Test Execution Pairs: @EnabledOnOs & @DisabledOnOs

Pro
01:43
19. Conditional Test Execution Pairs: @EnabledOnJre & @DisabledOnJre

Pro
00:47
20. Conditional Test Execution Pairs: @EnabledIfSystemProperty & @DisabledIfSystemProperty

Pro
01:30
21. Conditional Test Execution Pairs: @EnabledIfEnvironmentVariable & @DisabledIfEnvironmentVariable

Pro
01:08
22. Conditional Test Execution Pairs: @EnabledIf & @DisabledIf

Pro
02:19
23. Grouping tests with @Tag

Pro
01:50
24. @Nested & Effective BDD in JUnit 5

Pro
03:38
25. Running a test multiple times with @RepeatedTest

Pro
05:19
26. @ParameterizedTest with @ValueSource

Pro
03:11
27. @ParameterizedTest with @EnumSource

Pro
00:31
28. @ParameterizedTest with @MethodSource

Pro
02:30
29. @ParameterizedTest with @CsvSource & @CsvFileSource

Pro
01:44
30. Argument Conversion Techniques for Parameterized Tests

Pro
04:09
31. Writing a custom @Source for Parameterized Tests

Pro
04:31
32. Introduction to @TestFactory and Dynamic Tests

Pro
01:31
33. Grouping Dynamic Tests into Containers

Pro
01:55
34. Lifecycle Caveats for Dynamic Tests

Pro
01:06
35. Setting up Parallel Test Execution

Pro
02:47
36. Parallel Execution Strategies: Dynamic

Pro
02:02
37. Parallel Execution Strategies: Fixed

Pro
00:48
38. Parallel Execution Strategies: Custom

Pro
03:16
39. Synchronizing Parallel Test Execution with @ResourceLock

Pro
03:28

Something went wrong
Lesson added to playlist
Create new playlist
Name can't be empty