JUnit DisabledOnOs annotation not working

Viewed 413

This is my test class:

public class ClassTest {
    @Test
    @DisabledOnOs(value= {OS.WINDOWS})
    public void aLinuxTest() throws Exception {
        assertFalse(true);
    }       
}

pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.5.RELEASE</version>
</parent>

If I launch the test from my Windows operating system, aLinuxTest is executed.

It's not the expected behavior, what I am missing?

1 Answers

Are you sure, you are running Junit 5 and not Junit 4? E.g. import org.junit.jupiter.api.Test; to run Junit 5 and use the annotation @EnabledOnOs

Related