forked from scalatest/scalatest-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nb051436
committed
Dec 7, 2018
1 parent
39a1124
commit 65913b2
Showing
4 changed files
with
125 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.scalatest.tools.maven; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
|
||
/** | ||
* A verification that all the tests passed. | ||
* @phase verify | ||
* @goal verify | ||
*/ | ||
public class VerifyMojo extends AbstractScalaTestMojo { | ||
|
||
/** | ||
* The summary file to read integration test results from. | ||
* @parameter default-value="${project.build.directory}/surefire-reports/scalatest-summary.txt" property="scalatest.reportsDirectory" | ||
*/ | ||
private File summaryFile; | ||
|
||
public void execute() throws MojoExecutionException { | ||
try { | ||
File reportFile = new File(summaryFile.getAbsolutePath()); | ||
// FileReader reads text files in the default encoding. | ||
FileReader fileReader = | ||
new FileReader(reportFile); | ||
|
||
// Always wrap FileReader in BufferedReader. | ||
BufferedReader bufferedReader = | ||
new BufferedReader(fileReader); | ||
if(bufferedReader.readLine().contentEquals("failure")) { | ||
bufferedReader.close(); | ||
throw new MojoExecutionException("There are test failures"); | ||
} else { | ||
bufferedReader.close(); | ||
throw new MojoExecutionException("File has invalid content"); | ||
} | ||
} | ||
catch(FileNotFoundException ex) { | ||
throw new MojoExecutionException("Cannot find file: "+summaryFile.getAbsolutePath()); | ||
} | ||
catch(IOException ex) { | ||
throw new MojoExecutionException("IOException: "+ ex.toString()); | ||
} | ||
//} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters