Skip to content

Commit af977c0

Browse files
committed
Improve documentation for @EnabledIf and @DisabledIf test support
Closes gh-28157
1 parent 1bbcd70 commit af977c0

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

spring-test/src/main/java/org/springframework/test/context/junit/jupiter/DisabledIf.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,12 +50,23 @@
5050
* public {@literal @}interface DisabledOnMac {}
5151
* </pre>
5252
*
53+
* <p>Please note that {@code @DisabledOnMac} is meant only as an example of what
54+
* is possible. If you have that exact use case, please use the built-in
55+
* {@link org.junit.jupiter.api.condition.DisabledOnOs @DisabledOnOs(MAC)} support
56+
* in JUnit Jupiter.
57+
*
58+
* <p>Since JUnit 5.7, JUnit Jupiter also has a condition annotation named
59+
* {@link org.junit.jupiter.api.condition.DisabledIf @DisabledIf}. Thus, if you
60+
* wish to use Spring's {@code @DisabledIf} support make sure you import the
61+
* annotation type from the correct package.
62+
*
5363
* @author Sam Brannen
5464
* @author Tadaya Tsuyukubo
5565
* @since 5.0
5666
* @see SpringExtension
5767
* @see EnabledIf
5868
* @see org.junit.jupiter.api.Disabled
69+
* @see org.junit.jupiter.api.condition.DisabledIf
5970
*/
6071
@Target({ElementType.TYPE, ElementType.METHOD})
6172
@Retention(RetentionPolicy.RUNTIME)

spring-test/src/main/java/org/springframework/test/context/junit/jupiter/EnabledIf.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,11 +50,22 @@
5050
* public {@literal @}interface EnabledOnMac {}
5151
* </pre>
5252
*
53+
* <p>Please note that {@code @EnabledOnMac} is meant only as an example of what
54+
* is possible. If you have that exact use case, please use the built-in
55+
* {@link org.junit.jupiter.api.condition.EnabledOnOs @EnabledOnOs(MAC)} support
56+
* in JUnit Jupiter.
57+
*
58+
* <p>Since JUnit 5.7, JUnit Jupiter also has a condition annotation named
59+
* {@link org.junit.jupiter.api.condition.EnabledIf @EnabledIf}. Thus, if you
60+
* wish to use Spring's {@code @EnabledIf} support make sure you import the
61+
* annotation type from the correct package.
62+
*
5363
* @author Sam Brannen
5464
* @since 5.0
5565
* @see SpringExtension
5666
* @see DisabledIf
5767
* @see org.junit.jupiter.api.Disabled
68+
* @see org.junit.jupiter.api.condition.EnabledIf
5869
*/
5970
@Target({ElementType.TYPE, ElementType.METHOD})
6071
@Retention(RetentionPolicy.RUNTIME)

src/docs/asciidoc/testing.adoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,6 +1960,19 @@ example, you can create a custom `@EnabledOnMac` annotation as follows:
19601960
annotation class EnabledOnMac {}
19611961
----
19621962

1963+
[NOTE]
1964+
====
1965+
`@EnabledOnMac` is meant only as an example of what is possible. If you have that exact
1966+
use case, please use the built-in `@EnabledOnOs(MAC)` support in JUnit Jupiter.
1967+
====
1968+
1969+
[WARNING]
1970+
====
1971+
Since JUnit 5.7, JUnit Jupiter also has a condition annotation named `@EnabledIf`. Thus,
1972+
if you wish to use Spring's `@EnabledIf` support make sure you import the annotation type
1973+
from the correct package.
1974+
====
1975+
19631976
[[integration-testing-annotations-junit-jupiter-disabledif]]
19641977
===== `@DisabledIf`
19651978

@@ -2008,6 +2021,19 @@ example, you can create a custom `@DisabledOnMac` annotation as follows:
20082021
annotation class DisabledOnMac {}
20092022
----
20102023

2024+
[NOTE]
2025+
====
2026+
`@DisabledOnMac` is meant only as an example of what is possible. If you have that exact
2027+
use case, please use the built-in `@DisabledOnOs(MAC)` support in JUnit Jupiter.
2028+
====
2029+
2030+
[WARNING]
2031+
====
2032+
Since JUnit 5.7, JUnit Jupiter also has a condition annotation named `@DisabledIf`. Thus,
2033+
if you wish to use Spring's `@DisabledIf` support make sure you import the annotation type
2034+
from the correct package.
2035+
====
2036+
20112037
[[integration-testing-annotations-meta]]
20122038
==== Meta-Annotation Support for Testing
20132039

0 commit comments

Comments
 (0)