No tests found in TestClass. Didn't you forget the @Test annotation?

I get an error similar to this when performing my test:

org.mockito.exceptions.base.MockitoException: No tests found in TestCase Haven't you forgot @Test annotation? 

I, of course, have a method annotated with @Test . What am I doing wrong?

+5
source share
3 answers

This method must be explicitly declared as public :

 @Test public void asdf() { asdf... } 
+19
source

Import the junit package instead of the testng package.

+1
source

The only thing you need to change is the signature of the method. Make it public as shown below.

 @Test public void testMethod(){ System.out.println("This is a test method"); } 
+1
source

All Articles