Search in sources :

Example 1 with JunitQtestSubmitterImpl

use of com.qasymphony.ci.plugin.submitter.JunitQtestSubmitterImpl in project jenkin-qtest-plugin by QASymphony.

the class PushingResultAction method perform.

@SuppressWarnings("rawtypes")
@Override
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    PrintStream logger = listener.getLogger();
    JunitSubmitterRequest submitterRequest = configuration.createJunitSubmitRequest();
    if (null == submitterRequest) {
        LoggerUtils.formatError(logger, "Could not create JUnitSumitterRequest");
        return true;
    }
    submitterRequest.setBuildNumber(build.getNumber() + "").setBuildPath(build.getUrl()).setListener(listener);
    JunitSubmitter junitSubmitter = new JunitQtestSubmitterImpl();
    String buildResult = build.getResult() + "";
    if (Result.ABORTED.equals(build.getResult())) {
        LoggerUtils.formatWarn(logger, "Abort build action.");
        storeWhenNotSuccess(submitterRequest, junitSubmitter, build, buildResult, logger, JunitSubmitterResult.STATUS_CANCELED);
        return true;
    }
    showInfo(logger);
    if (!validateConfig(configuration)) {
        LoggerUtils.formatWarn(logger, "Invalid configuration to qTest, reject submit test results.");
        storeWhenNotSuccess(submitterRequest, junitSubmitter, build, buildResult, logger, JunitSubmitterResult.STATUS_FAILED);
        return true;
    }
    if (null == checkProjectNameChanged(build, listener)) {
        storeWhenNotSuccess(submitterRequest, junitSubmitter, build, buildResult, logger, JunitSubmitterResult.STATUS_CANCELED);
        return true;
    }
    List<AutomationTestResult> automationTestResults = readTestResults(build, launcher, listener, logger);
    if (automationTestResults.isEmpty()) {
        LoggerUtils.formatWarn(logger, "No JUnit test result found.");
        storeWhenNotSuccess(submitterRequest, junitSubmitter, build, buildResult, logger, JunitSubmitterResult.STATUS_SKIPPED);
        LoggerUtils.formatHR(logger);
        return true;
    }
    submitterRequest.setTestResults(automationTestResults);
    JunitSubmitterResult result = submitTestResult(submitterRequest, build, listener, junitSubmitter, automationTestResults);
    if (null == result) {
        // if have no test result, we do not break build flow
        return true;
    }
    saveConfiguration(build, result, logger);
    storeResult(submitterRequest, build, buildResult, junitSubmitter, result, logger);
    LoggerUtils.formatHR(logger);
    return true;
}
Also used : PrintStream(java.io.PrintStream) AutomationTestResult(com.qasymphony.ci.plugin.model.AutomationTestResult) JunitSubmitterResult(com.qasymphony.ci.plugin.submitter.JunitSubmitterResult) JunitSubmitter(com.qasymphony.ci.plugin.submitter.JunitSubmitter) JunitQtestSubmitterImpl(com.qasymphony.ci.plugin.submitter.JunitQtestSubmitterImpl) JunitSubmitterRequest(com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest)

Aggregations

AutomationTestResult (com.qasymphony.ci.plugin.model.AutomationTestResult)1 JunitQtestSubmitterImpl (com.qasymphony.ci.plugin.submitter.JunitQtestSubmitterImpl)1 JunitSubmitter (com.qasymphony.ci.plugin.submitter.JunitSubmitter)1 JunitSubmitterRequest (com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest)1 JunitSubmitterResult (com.qasymphony.ci.plugin.submitter.JunitSubmitterResult)1 PrintStream (java.io.PrintStream)1