blob: 74fabd4ef3ec264dea642c02ef14485aff77f091 [file] [log] [blame]
------
Accessing Test Classes
------
Benjamin Bentmann
------
2008-08-02
------
~~ 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
Accessing Test Classes
In case your pre-/post-build scripts perform complex operations that you would rather like to refactor out into some
utility class instead of copy&pasting them in each script, you can use the parameter <<<addTestClassPath>>>:
+----
<project>
<build>
<plugins>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>${project.version}</version>
<configuration>
<addTestClassPath>true</addTestClassPath>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
+----
Setting <<<addTestClassPath>>> to <<<true>>> will prepend the directories <<<$\{project.build.testOutputDirectory\}>>>,
<<<$\{project.build.outputDirectory\}>>> and all dependencies of your project to the class path of the script
interpreter. Among others, this allows you to create some utility classes in your test source tree and use this code
for the hook scripts.
<Note:> Of course, this requires your test classes to be compiled before running the integration tests but this is
usually the case if you employ the Invoker Plugin during the lifecycle phase <<<integration-test>>>.