Java @Disabled annotation in class or test not taken into account

Hi,

I just started using Travis CI today and there is something I can’t understand. I wanted to disable some of my tests so as usual, I used the @Disabled annotation on my class (or on some of my tests) like this :

import org.junit.jupiter.api.Disabled;

@Disabled
public class TwitterClientTest {

Locally everything is OK, the tests are not launched :
image

But in TravisCI after having push my branch, the @Disabled annotation is ignored and all the tests are ran and fail:

Failed tests: com.socialmediaraiser.twitter.nrt.TwitterClientTest.testGetFollowingIdsById()
com.socialmediaraiser.twitter.nrt.TwitterClientTest.testGetFollowersIdsById()
com.socialmediaraiser.twitter.nrt.TwitterClientTest.testGetFollowersUsersById()
 etc...

Any idea about what I did wrong ? I’m Using JDK 12 and JUnit Jupiter 5.4.2.

Thanks !

Please check your code. I don’t think this is an issue with Travis CI.

For example:


(I’m not saying this is your issue. I’m just pointing out that something else is probably at play.)

If i’m the first to have this problem with Travis sure it comes from my side. The only strange thing is that it works locally but I’ll dig in.

Thanks !

Your local machine probably has something (local cache, different JUnit version, plugins, etc.) that our VM doesn’t. Try starting with a clean machine (a Docker image or whatever), to confirm.

1 Like

I’ll do it, thank you very much !

No issue of Travis CI.

First, run your tests via mvn verify locally and make sure they pass/skip as expected. Likely, you need to help Surefire here and there to load the JUnit Platform provider.

Then, invoke the same command (mvn verify) on Travis CI.

Exact, I just had to add it on my pom and it worked :

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M4</version>
            </plugin>
1 Like