
org.evosuite.maven.InfoMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of evosuite-maven-plugin Show documentation
Show all versions of evosuite-maven-plugin Show documentation
Plugin used to run EvoSuite to automatically generate high coverage JUnit tests
The newest version!
/**
* Copyright (C) 2010-2018 Gordon Fraser, Andrea Arcuri and EvoSuite
* contributors
*
* This file is part of EvoSuite.
*
* EvoSuite is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* EvoSuite is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with EvoSuite. If not, see .
*/
package org.evosuite.maven;
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuilder;
import org.eclipse.aether.RepositorySystemSession;
import org.evosuite.maven.util.EvoSuiteRunner;
/**
* Obtain info of generated tests so far
*/
@Mojo( name = "info")
public class InfoMojo extends AbstractMojo{
@Parameter(defaultValue = "${plugin.artifacts}", required = true, readonly = true)
private List artifacts;
@Component
private ProjectBuilder projectBuilder;
@Parameter(defaultValue="${repositorySystemSession}", required = true, readonly = true)
private RepositorySystemSession repoSession;
@Parameter(defaultValue = "${project}", required = true, readonly = true)
private MavenProject project;
@Override
public void execute() throws MojoExecutionException,MojoFailureException{
getLog().info("Going to query EvoSuite info on current project");
List params = new ArrayList<>();
params.add("-continuous");
params.add("info");
EvoSuiteRunner runner = new EvoSuiteRunner(getLog(),artifacts,projectBuilder,repoSession);
runner.registerShutDownHook();
boolean ok = runner.runEvoSuite(project.getBasedir().toString(),params);
if(!ok){
throw new MojoFailureException("Failed to correctly execute EvoSuite");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy