Java maven project, when building mvn verify package, tests are run as it should, when you try to mvn test (from the compiler or console) a line appears
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ GreetTime --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ and it immediately goes to the end. It’s so that my tests are just skipped, I think that somewhere I haven’t indicated the path to the necessary folder. How to make the tests run with the command mvn test . Because in the future I will need to run tests at build (Travis CI), at the moment I just can not see the tests. With mvn test -Dtest=IntegrationTest everything works, but this option is not suitable. When specifying <testClassesDirectory>Greeting\target\test-classes</testClassesDirectory> I get no Tests to run error
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mavenTime</groupId> <artifactId>GreetTime</artifactId> <packaging>jar</packaging> <version>1.0</version> <name>GreetJar</name> <url>http://maven.apache.org</url> <properties> <log4j.version>1.2.12</log4j.version> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12.4</version> <configuration> <skipTests>false</skipTests> <excludes> <exclude>**/*IntegrationTest.java</exclude> </excludes> <testSourceDirectory>${project.build.testSourceDirectory}</testSourceDirectory> <reportsDirectory>Greeting\target\surefire-reports</reportsDirectory> </configuration> <executions> <execution> <id>integration-test</id> <goals> <goal>test</goal> </goals> <phase>integration-test</phase> <configuration> <excludes> <exclude>none</exclude> </excludes> <includes> <include>**/*IntegrationTest*.java</include> <include>**/*IntegrationTest.java</include> <include>**/*IntegrationTest*.java</include> </includes> <testSourceDirectory>Greeting\target\surefire-reports</testSourceDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib</classpathPrefix> <mainClass>Main</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> <configuration> <archive> <manifest> <mainClass>Main</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>${jdk.version}</source> <target>${jdk.version}</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> <scope>compile</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <scope>test</scope> <exclusions> <exclusion> <groupId>org.testng</groupId> <artifactId>testng</artifactId> </exclusion> </exclusions> </dependency> </dependencies> </project>
main/javaandtest/javaand when you run apackage,test orinstallmvn, it scans thetesttoolbox for tests and runs them. And no additional manipulations with the pom-a configuration are required - GVArt Sept