Skip to content

Commit 0996b03

Browse files
asimellTattoo
andauthored
JENKINS-72538 - SKIP status configurable when calculating all tests (#77)
* Deprecate criticalPassed and criticalFailed * Deprecate more criticalPassed/Failed stuff * Remove critical tests from the latest results table * Add possibility to optionally include skip status when calculating pass percentage * Update readme to match current behaviour * Update src/main/resources/hudson/plugins/robot/RobotPublisher/config.properties Co-authored-by: Tatu Kairi <[email protected]> * Update src/test/java/hudson/plugins/robot/model/RobotResultTest.java Co-authored-by: Tatu Kairi <[email protected]> * Update src/test/java/hudson/plugins/robot/model/RobotResultTest.java Co-authored-by: Tatu Kairi <[email protected]> * Update src/test/java/hudson/plugins/robot/tokens/RobotPassTokenMacroTest.java Co-authored-by: Tatu Kairi <[email protected]> * Update src/test/java/hudson/plugins/robot/tokens/RobotPassRatioTokenMacroTest.java Co-authored-by: Tatu Kairi <[email protected]> * Update src/test/java/hudson/plugins/robot/tokens/RobotPassPercentageTokenMacroTest.java Co-authored-by: Tatu Kairi <[email protected]> * Update src/test/java/hudson/plugins/robot/model/RobotResultTest.java Co-authored-by: Tatu Kairi <[email protected]> * Update src/main/resources/hudson/plugins/robot/RobotStep/config.properties Co-authored-by: Tatu Kairi <[email protected]> * Add unit tests to check new getPassPercentage behaviour * Update doc/README.md Co-authored-by: Tatu Kairi <[email protected]> --------- Co-authored-by: Tatu Kairi <[email protected]>
1 parent cd4cde3 commit 0996b03

29 files changed

+677
-631
lines changed

doc/README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,14 @@ and [here](https://content-security-policy.com/) how to change you CSP settings
178178
but be aware that **Changing CSP settings will potentially expose you Jenkins instance for
179179
security vulnerabilities**.
180180

181-
### Robot Framework 4.x compatibility
181+
### Robot Framework 4.x+ compatibility
182182

183-
The plugin supports both Robot Framework 3.x and 4.x output files. However, in order to support both, the plugin
184-
shows some extra information for both. [In Robot Framework 4.0 test criticality was removed and "SKIP" status was added](https://github.com/robotframework/robotframework/blob/master/doc/releasenotes/rf-4.0.rst). So for 3.x the
185-
results overview will show a `Skipped` column, which will always be 0 and for Robot Framework 4.x output files
186-
the `Critical tests` row will always be 0.
183+
:heavy_exclamation_mark: As we're preparing to drop support for RF 3.x, the `onlyCritical` flag has been deprecated and no
184+
longer has any effect. It will be removed in the future, but for now it's available for the transition period.
185+
A new flag `countSkippedTests` has been added to the pipeline step to allow users to choose whether to count skipped
186+
tests in the pass percentage calculation.
187187

188-
Skipped tests aren't taken into account when calculating pass percentage, but they are calculated to the total
189-
amount of tests.
190-
191-
Because criticality was removed in Robot Framework 4.0, having the `Use thresholds for critical tests only` checkbox
192-
checked will always result in a passing step (because pass percentage is always considered to be 100% when there are
193-
0 tests). In order to have set build status correctly, you **must** uncheck the checkbox or use `onlyCritical: false`
194-
in your pipeline when you call `robot`.
195-
196-
We are planning of dropping support for Robot Framework 3.x and earlier some time in distant future.
188+
The plugin still supports RF 3.x, but no longer takes criticality into account. If you want to use RF 3.x with criticality, please downgrade to the last major version (4.0.0)
197189

198190
### Overall Screenshots
199191

src/main/java/hudson/plugins/robot/AggregatedRobotAction.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,33 +109,34 @@ public static class AggregatedRobotResult extends RobotResult {
109109

110110
private static final long serialVersionUID = 1L;
111111
private final transient AggregatedRobotAction parent;
112-
private int passed, failed, skipped, criticalPassed, criticalFailed;
112+
private int passed, failed, skipped;
113113

114114
public AggregatedRobotResult(AggregatedRobotAction parent) {
115115
this.parent = parent;
116116
}
117117

118118
public void addResult(RobotResult result) {
119-
criticalFailed += result.getCriticalFailed();
120-
criticalPassed += result.getCriticalPassed();
121119
failed += result.getOverallFailed();
122120
passed += result.getOverallPassed();
123121
skipped += result.getOverallSkipped();
124122
}
125123

124+
@Deprecated
126125
@Override
127126
public long getCriticalPassed() {
128-
return criticalPassed;
127+
return this.getOverallPassed();
129128
}
130129

130+
@Deprecated
131131
@Override
132132
public long getCriticalFailed() {
133-
return criticalFailed;
133+
return this.getOverallFailed();
134134
}
135135

136+
@Deprecated
136137
@Override
137138
public long getCriticalTotal() {
138-
return criticalFailed + criticalPassed;
139+
return this.getOverallTotal();
139140
}
140141

141142
@Override

src/main/java/hudson/plugins/robot/RobotBuildAction.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public class RobotBuildAction extends AbstractTestResultAction<RobotBuildAction>
6565
private RobotResult result;
6666
private String xAxisLabel;
6767

68+
private boolean countSkippedTests;
69+
6870
static {
6971
XSTREAM.alias("result",RobotResult.class);
7072
XSTREAM.alias("suite",RobotSuiteResult.class);
@@ -83,7 +85,8 @@ public class RobotBuildAction extends AbstractTestResultAction<RobotBuildAction>
8385
* @param enableCache Whether we want to enable caching or not
8486
*/
8587
public RobotBuildAction(Run<?, ?> build, RobotResult result,
86-
String outputPath, TaskListener listener, String logFileLink, String logHtmlLink, boolean enableCache, String xAxisLabel) {
88+
String outputPath, TaskListener listener, String logFileLink, String logHtmlLink, boolean enableCache, String xAxisLabel,
89+
boolean countSkippedTests) {
8790
super();
8891
super.onAttached(build);
8992
this.build = build;
@@ -92,6 +95,7 @@ public RobotBuildAction(Run<?, ?> build, RobotResult result,
9295
this.logHtmlLink = logHtmlLink;
9396
this.enableCache = enableCache;
9497
this.xAxisLabel = xAxisLabel;
98+
this.countSkippedTests = countSkippedTests;
9599
setResult(result, listener);
96100
}
97101

@@ -333,4 +337,12 @@ public String getUrlName() {
333337
public List<RobotCaseResult> getAllTests() {
334338
return getResult().getAllCases();
335339
}
340+
341+
public boolean isCountSkippedTests() {
342+
return countSkippedTests;
343+
}
344+
345+
public void setCountSkippedTests(boolean countSkippedTests) {
346+
this.countSkippedTests = countSkippedTests;
347+
}
336348
}

src/main/java/hudson/plugins/robot/RobotParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ private RobotCaseResult processTest(XMLStreamReader reader, RobotSuiteResult res
293293
caseResult.setLogFile(this.logFileName);
294294
//parse attributes
295295
caseResult.setName(reader.getAttributeValue(null, "name"));
296-
setCriticalityIfAvailable(reader, caseResult);
296+
//setCriticalityIfAvailable(reader, caseResult);
297297
caseResult.setId(reader.getAttributeValue(null, "id"));
298298
//parse test tags
299299
caseResult.setDescription("");
@@ -346,7 +346,7 @@ private RobotCaseResult processTest(XMLStreamReader reader, RobotSuiteResult res
346346
if (schemaVersion >= 5) {
347347
caseResult.setElapsedTime(reader.getAttributeValue(null, elapsedLocalName));
348348
}
349-
setCriticalityIfAvailable(reader, caseResult);
349+
// setCriticalityIfAvailable(reader, caseResult);
350350
while(reader.hasNext()){
351351
reader.next();
352352
if(reader.isCharacters()){

0 commit comments

Comments
 (0)