Używam Mavena z wieloma modułami. Istnieją 3 projekty.Maven nie wykonuje żadnego testu jednostkowego
foo(the parent project)
foo-core
foo-bar
skonfigurować wszystkie zależności i wtyczki w foo
„s pom:
<modules>
<module>../foo-core</module>
<module>../foo-bar</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
...
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.14.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
Istnieje kilka klas bazowych i util zajęcia dla testów jednostkowych w foo-core
, więc dodać maven-jar-plugin
w foo-core
projektu udostępnić go foo-bar
:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Kiedy wykonać test
bramka, otrzymałem wynik w następujący sposób:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
parallel='none', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Mam testy w moich projektach. Ale dlaczego nie uruchamia żadnego z nich?
Czy nazwy plików testowych spełniać te wymienione na stronie Surefire? http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html –
@Grzegorz Tak. Wszystkie pliki testowe mają nazwę *** Tests.java. –
Jeśli tak, zobacz odpowiedź. –