0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Mavenで単体テストのレポートを出力する。

Posted at

Mavenで単体テスト結果をレポート出力してみました。その時の設定メモを残したいと思います。
Gradleの場合と同様にプラグインを入れて出力しています。(Gradleの場合はapply plugin: 'java')

※あくまでメモなのでそのままでは実行できない可能性が高いです。

使用するプラグイン

  • maven-surefire-report-plugin
  • maven-site-plugin

maven-surefire-report-pluginだけでも出力はできますが、CSSなどが出力されません(チェックマークも表示されない)。
そのため、maven-site-pluginで作成できるプロジェクトサイトに使われるCSSを使うことにします。

設定

pom.xmlにプラグインの設定を追加します。(...は省略)

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
...
<build>
...
	<plugins>
	...
		<!-- report -->
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-surefire-report-plugin</artifactId>
			<version>3.0.0-M4</version>
		</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-site-plugin</artifactId>
			<version>3.9.0</version>
		</plugin>
	</plugins>
</build>
...
</project>

レポート出力

pom.xmlが存在するフォルダで、
以下のコマンドを実行してレポート出力します。

レポート出力
$ mvn clean    # 実行しない場合、前回の結果が混ざってしまう
$ mvn site:site -DskipTests
$ mvn -Dtest=**/sample/*Test surefire-report:report

参考

https://maven.apache.org/surefire/maven-surefire-plugin/index.html
https://maven.apache.org/surefire/maven-surefire-report-plugin/index.html
https://maven.apache.org/plugins/maven-site-plugin/index.html
https://kikutaro777.hatenablog.com/entry/2013/01/13/201253

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?