
io.github.carousell.testrails.CreateRunMojo Maven / Gradle / Ivy
package io.github.carousell.testrails;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.github.carousell.testrails.services.TestRailService;
/** Mojo for creating a Testrail run */
@Mojo(name = "createrun")
public class CreateRunMojo extends AbstractMojo {
private static final Logger LOG = LoggerFactory.getLogger(CreateRunMojo.class);
private static final String TEST_PACKAGES_TABLE_NAME = "testPackages";
@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
@Parameter(defaultValue = "${project.basedir}/src/test/resources/features")
private String featuresSourceDirectory;
@Parameter(required = true, readonly = true)
private String url;
@Parameter(required = true, readonly = true)
private int projectId;
@Parameter(required = true, readonly = true)
private int suiteId;
@Parameter(required = true, readonly = true)
private int planId;
@Parameter(required = true, readonly = true)
private String testPlatform;
@Parameter(required = true, readonly = true)
private String testType;
@Parameter(readonly = true)
private String testStatus;
@Parameter(required = true, readonly = true)
private String username;
@Parameter(required = true, readonly = true)
private String password;
@Parameter(defaultValue = "generated by testrail-maven-plugin")
private String testRunName;
@Parameter(property = "runId", readonly = true)
private int runId;
@Parameter(property = "entryId", readonly = true)
private String entryId;
public void execute() {
LOG.info("Get Testrail Maven Plug-in Configuration : " +
"-DprojectId : {}, " +
"-DsuiteId : {}, " +
"-DplanId : {}," +
"-DtestPlatform : {}, " +
"-DtestType : {}, " +
"-DtestStatus : {}, " +
"-DtestRunName : {} ",
projectId, suiteId, planId, testPlatform, testType, testStatus, testRunName);
TestRailService testRailService = new TestRailService(url, username, password, projectId, suiteId, testPlatform);
testRailService.filteredTestCases(testPlatform, testType, testStatus);
testRailService.createTestRun(planId, suiteId, testRunName);
String runId = testRailService.getRunId();
String entryId = testRailService.getEntryId();
LOG.info("Setting RunId {} as Maven property", runId);
project.getProperties().put("testRunId", runId);
LOG.info("Setting entryId {} as Maven property", entryId);
project.getProperties().put("entryId", entryId);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy