Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mockito test not seen by Maven?

I'm building my package with maven (runs without problems) and then I try to make a Mockito test for a class.

Dependencies in the pom.xml are as follows:

<dependencies>
  <dependency>
  <groupId>org.apache.maven</groupId>
  <artifactId>maven-project</artifactId>
  <version>2.0.6</version>
  <scope>test</scope>
</dependency>
    <dependency>
     <groupId>org.mockito</groupId>
    <artifactId>mockito-all</artifactId>
    <version>1.9.5</version>
    <scope>test</scope>
    </dependency>
  </dependencies>
</project>

The mockito-test looks like this:

package Person;

import static org.mockito.Mockito.*;
import java.io.IOException;

public class AppTest {

public void test() throws IOException{
PersonManagement mockedPM = mock(PersonManagement.class); 
//automatically creates an instance variable of type person

mockedPM.updatePerson("test","test");
//updates this.person
verify(mockedPM).updatePerson("test","test");
}
}

After launching mvn package the test results show, that no test were run (the file including the test is found and recognized, because when I put syntax mistakes there, compiler recognizes these)

I would appreciate any help, thanks

like image 586
IAM Avatar asked Dec 20 '22 06:12

IAM


1 Answers

Mockito is not a testing framework. It's a mocking API. Use JUnit or TestNG. These are testing frameworks. Both simply require some annotations to be placed on test methods.

And of course, your JUnit or TestNG tests will use the Mockito API internally, to mock dependencies.

like image 61
JB Nizet Avatar answered Jan 04 '23 17:01

JB Nizet