I'm guessing the assembly is trying to run before the test-compile
phase, in which case there will be no classes to include. Or you are running mvn assembly:assembly
, in which case the default lifecycle will not be run and the test classes not compiled. You could bind the execution of the assembly plugin to a later phase (e.g. package
) to ensure the processing is completed before the assembly is constructed.
However you don't need to use an assembly to package test-classes. This can be done by configuring the jar plugin to package the test jar as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
By default the test jar will be attached to the project, and when installed/deployed will have the classifier tests
.
If you must use the assembly, here is how you bind it to the default lifecycle so that it will be run when package is called.
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/test-assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-test-assembly</id>
<phase>package</phase> <!-- append to the packaging phase. -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
If this still does not work, it suggests you are using a non-standard packaging type that doesn't perform the relevant goals for test processing, or your test sources are defined in a non-standard location so they are not being processed. If you are still having trouble can you append the output from your build to your question?