Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added possibility to mark build as unstable when any of non-critical tests fail #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/main/java/hudson/plugins/robot/RobotPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class RobotPublisher extends Recorder implements Serializable,

//Default to true
private boolean onlyCritical = true;
private boolean nonCritical = true;


/**
Expand All @@ -87,18 +88,22 @@ public class RobotPublisher extends Recorder implements Serializable,
* Threhold of test pass percentage for unstable builds
* @param onlyCritical
* True if only critical tests are included in pass percentage
* @param nonCritical
* True if build should be marked unstable when any of non-critical tests failed
*/
@DataBoundConstructor
public RobotPublisher(String outputPath, String outputFileName,
String reportFileName, String logFileName, double passThreshold,
double unstableThreshold, boolean onlyCritical, String logFileLink, String otherFiles) {
double unstableThreshold, boolean onlyCritical, boolean nonCritical,
String logFileLink, String otherFiles) {
this.outputPath = outputPath;
this.outputFileName = outputFileName;
this.reportFileName = reportFileName;
this.passThreshold = passThreshold;
this.unstableThreshold = unstableThreshold;
this.logFileName = logFileName;
this.onlyCritical = onlyCritical;
this.onlyCritical = onlyCritical;
this.nonCritical = nonCritical;
this.logFileLink = logFileLink;

String[] filemasks = otherFiles.split(",");
Expand All @@ -107,6 +112,18 @@ public RobotPublisher(String outputPath, String outputFileName,
}
this.otherFiles = filemasks;
}

/**
* Constructor for backward compatibility with existing unit tests
*/
public RobotPublisher(String outputPath, String outputFileName,
String reportFileName, String logFileName, double passThreshold,
double unstableThreshold, boolean onlyCritical,
String logFileLink, String otherFiles) {
this(outputPath, outputFileName, reportFileName, logFileName,
passThreshold, unstableThreshold, onlyCritical, false,
logFileLink, otherFiles);
}

/**
* Gets the output path of Robot files
Expand Down Expand Up @@ -180,6 +197,15 @@ public boolean getOnlyCritical() {
return onlyCritical;
}

/**
* Gets if failures of non-critical tests should cause build to be unstable.
*
* @return
*/
public boolean getNonCritical() {
return nonCritical;
}

/**
* Return the filename to be rendered in the job front page
* @return null if empty file configured
Expand Down Expand Up @@ -396,6 +422,8 @@ protected Result getBuildResult(AbstractBuild<?, ?> build,
return Result.FAILURE;
} else if (passPercentage < getPassThreshold()) {
return Result.UNSTABLE;
} else if (nonCritical && (passPercentage != result.getPassPercentage(!onlyCritical))) {
return Result.UNSTABLE;
}
return Result.SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ limitations under the License.
<f:entry field="onlyCritical">
<f:checkbox default="true"/>${%thresholds.onlycritical}
</f:entry>
<f:entry field="nonCritical">
<f:checkbox default="true"/>${%thresholds.noncritical}
</f:entry>
</table>
</f:entry>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ advanced.otherfiles=Other files to copy
advanced.otherfiles.description=Comma separated list of robot related artifacts to be saved

thresholds.label=Thresholds for build result
thresholds.onlycritical=Use thresholds for critical tests only
thresholds.onlycritical=Use thresholds for critical tests only
thresholds.noncritical=Mark build unstable if any of non-critical tests failed