Skip to content

Instantly share code, notes, and snippets.

@hokuma
Created February 25, 2013 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hokuma/5029662 to your computer and use it in GitHub Desktop.
Save hokuma/5029662 to your computer and use it in GitHub Desktop.
テストコードと依存するライブラリをjarにまとめてCLIで実行する ref: http://qiita.com/items/e489d02f9622ce73b235
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptors>
<descriptor>src/test/resources/assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
...
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>test-jar-with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>test</scope>
</dependencySet>
</dependencySets>
</assembly>
java -cp 上で作ったjar org.junit.runner.JUnitCore テストが記載されたクラス名
java -cp smoke-test-0.0.1-SNAPSHOT-test-jar-with-dependencies.jar org.junit.runner.JUnitCore sample.smoketest.SampleSpec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment