Skip to content

Commit 2bbcc50

Browse files
authored
BAEL-6282 Add Native Image Condition (#13739)
1 parent 00f1479 commit 2bbcc50

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/conditional/ConditionalAnnotationsUnitTest.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,7 @@
22

33
import org.junit.jupiter.api.RepeatedTest;
44
import org.junit.jupiter.api.Test;
5-
import org.junit.jupiter.api.condition.DisabledForJreRange;
6-
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
7-
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
8-
import org.junit.jupiter.api.condition.DisabledOnJre;
9-
import org.junit.jupiter.api.condition.DisabledOnOs;
10-
import org.junit.jupiter.api.condition.EnabledForJreRange;
11-
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
12-
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
13-
import org.junit.jupiter.api.condition.EnabledOnJre;
14-
import org.junit.jupiter.api.condition.EnabledOnOs;
15-
import org.junit.jupiter.api.condition.JRE;
16-
import org.junit.jupiter.api.condition.OS;
5+
import org.junit.jupiter.api.condition.*;
176
import org.slf4j.Logger;
187
import org.slf4j.LoggerFactory;
198

@@ -44,6 +33,18 @@ public void shouldOnlyRunOnJava10And11() {
4433
LOGGER.debug("runs with java 10 and 11");
4534
}
4635

36+
@Test
37+
@EnabledInNativeImage
38+
void shouldOnlyRunWithinNativeImage() {
39+
LOGGER.debug("Should run only within native images.");
40+
}
41+
42+
@Test
43+
@DisabledInNativeImage
44+
void shouldNeverRunWithinNativeImage() {
45+
LOGGER.debug("Shouldn't run within native images.");
46+
}
47+
4748
@Test
4849
@EnabledForJreRange(min = JRE.JAVA_8, max = JRE.JAVA_13)
4950
public void shouldOnlyRunOnJava8UntilJava13() {

0 commit comments

Comments
 (0)