blob: 07953e9e735fdf070c62c419d4f78bf5f3db37a2 [file] [log] [blame]
------
Guide to using attached tests
------
Jason van Zyl
------
2005-10-12
------
~~ Licensed to the Apache Software Foundation (ASF) under one
~~ or more contributor license agreements. See the NOTICE file
~~ distributed with this work for additional information
~~ regarding copyright ownership. The ASF licenses this file
~~ to you under the Apache License, Version 2.0 (the
~~ "License"); you may not use this file except in compliance
~~ with the License. You may obtain a copy of the License at
~~
~~ http://www.apache.org/licenses/LICENSE-2.0
~~
~~ Unless required by applicable law or agreed to in writing,
~~ software distributed under the License is distributed on an
~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~~ KIND, either express or implied. See the License for the
~~ specific language governing permissions and limitations
~~ under the License.
~~ NOTE: For help with the syntax of this file, see:
~~ http://maven.apache.org/doxia/references/apt-format.html
Guide to using attached tests
Many times you may want to reuse the tests that you have created for a project in another. For example if you have
written <<<foo-core>>> and it contains test code in the <<<$\{basedir\}/src/test/java>>> it would be useful to package
up those compiled tests in a JAR and deploy them for general reuse. To do this you would configure the
<<<maven-jar-plugin>>> as follows:
+----+
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
+----+
* Installing the attached test JAR
In order to install the attached test JAR you simply use the standard <<<install>>> phase by executing
the following command:
+----+
mvn install
+----+
* Deploying the attached test JAR
In order to deploy the attached test JAR you simply use the standard <<<deploy>>> phase by executing
the following command:
+----+
mvn deploy
+----+
* Using the attached test JAR
In order to use the attached test JAR that was created above you simply specify a dependency on the main
artifact with a specified type of <<<test-jar>>> and the <<<classifier>>>.
+----+
<project>
...
<dependencies>
<dependency>
<groupId>com.myco.app</groupId>
<artifactId>foo</artifactId>
<version>1.0-SNAPSHOT</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
...
</project>
+----+