![JAR search and dependency download from the Maven repository](/logo.png)
io.guixer.maven.VerifySurefireReportsMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of guixer-maven-plugin Show documentation
Show all versions of guixer-maven-plugin Show documentation
Maven plugin to handle logs emitted by tests run over guixer-tools.
package io.guixer.maven;
import java.io.File;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import net.avcompris.binding.dom.helper.DomBinderUtils;
@Mojo(name = "verify", defaultPhase = LifecyclePhase.VERIFY)
public class VerifySurefireReportsMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", required = true, readonly = true)
private MavenProject project;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
// Ignore race issues
//
final MavenProject project = this.project;
final File targetDir = AbstractGuixerOutMojo.getTargetDir(project);
final File surefireReportsDir = new File(targetDir, "surefire-reports");
if (!surefireReportsDir.isDirectory()) {
throw new MojoExecutionException(
"Cannot find surefire-reports directory: " + surefireReportsDir.getAbsolutePath());
}
for (final File testReportXmlFile : surefireReportsDir.listFiles(file -> {
if (file.isFile()) {
final String fileName = file.getName();
if (fileName.startsWith("TEST-") && fileName.endsWith(".xml")) {
return true;
}
}
return false;
})) {
final SurefireTestReport testReport = DomBinderUtils.xmlContentToJava(testReportXmlFile,
SurefireTestReport.class);
if (testReport.getErrors() != 0 || testReport.getFailures() != 0) {
throw new MojoFailureException("There are test failures.");
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy