简体   繁体   中英

Running maven test on a specific class - [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test

Getting the following issue. When I run mvn test -Dtest=MyClassTest

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test  
(default-test) on project my-project: No tests were executed!  (Set -DfailIfNoTests=false to 
ignore this error.) -> [Help 1]

But I have 10 other classes in the same project but on a different path. I ran all of them like this and those all run fine. But mvn test is not identifying just this one. Could there be any problems?

I reviewed the same errors that people got, but was proposed different solutions like upgrade, etc. But for me, all tests run fine, except this one. So I am kind of in limbo, if I am missing something.

For those that have the same issue. Its my blunder (maybe). The @Test annotated method has no access specifier. I just use void method(). I added public and it started working!

Thanks @user2507946. Running from IDE help solve the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM