This repository has been archived by the owner on Jun 13, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FIXED JENKINS-6446] Modified the scoring mechanism as follows to avo…
…id the inconsistency in granting marks. Passing test added: +1 removed: -1 Failing test added: -1 removed: +1 Skipped test (no marks given or reduced) added: 0 removed: 0 Following is the details of how all scenarios are handled. Passing Tests Passing test added = +1 [Increases passing count = +1] Passing test removed = -1 [Decreases passing count = -1] Passing an already failing test = +2 [Decreases failing count = +1] [Increases passing count = +1] Passing an already skipped test = +1 [Decreases skipped count = 0] [Increases passing count = +1] Failing tests Failing test added = -1 [Increases failing count = -1] Failing test removed = +1 [Decreases failing count = +1] Failing an already passing test = -2 [Decreases passing count = -1] [Increases failing count = -1] Failing an already skipped test = -1 [Decreases skipped count = 0] [Increases failing count = -1] Skipped tests Skipped test added = 0 [Increases skipped count = 0] Skipped test removed = 0 [Decreases skipped count = 0] Skipped an already passing test = -1 [Decreases passing count = -1] [Increases skipped count = 0] Skipped an already failing test = +1 [Decreases failing count = +1] [Increases skipped count = 0]
- Loading branch information
Showing
18 changed files
with
334 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/hudson/plugins/cigame/rules/unittesting/AbstractFailedTestsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package hudson.plugins.cigame.rules.unittesting; | ||
|
||
import hudson.plugins.cigame.model.RuleResult; | ||
import hudson.tasks.test.AbstractTestResultAction; | ||
|
||
/** | ||
* Rule that gives points for increasing or decreasing the number of failed | ||
* tests. This is done by comparing the current with the previous build. | ||
* | ||
* @author <a href="www.digizol.com">Kamal Mettananda</a> | ||
* @since 1.20 | ||
*/ | ||
public abstract class AbstractFailedTestsRule extends AbstractUnitTestsRule { | ||
|
||
protected abstract RuleResult<Integer> evaluate(int failedTestDiff); | ||
|
||
@Override | ||
protected RuleResult<Integer> evaluate(AbstractTestResultAction<?> testResult, | ||
AbstractTestResultAction<?> previousTestResult) { | ||
|
||
return evaluate(testResult.getFailCount() - previousTestResult.getFailCount()); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/hudson/plugins/cigame/rules/unittesting/AbstractPassedTestsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package hudson.plugins.cigame.rules.unittesting; | ||
|
||
import hudson.plugins.cigame.model.RuleResult; | ||
import hudson.tasks.test.AbstractTestResultAction; | ||
|
||
/** | ||
* Rule that gives points for increasing or decreasing the number of passed | ||
* tests. This is done by comparing the current with the previous build. | ||
* | ||
* @author <a href="www.digizol.com">Kamal Mettananda</a> | ||
* @since 1.20 | ||
*/ | ||
public abstract class AbstractPassedTestsRule extends AbstractUnitTestsRule { | ||
|
||
protected abstract RuleResult<Integer> evaluate(int passedTestDiff); | ||
|
||
@Override | ||
protected RuleResult<Integer> evaluate(AbstractTestResultAction<?> testResult, | ||
AbstractTestResultAction<?> previousTestResult) { | ||
|
||
return evaluate((testResult.getTotalCount() - testResult.getFailCount() - testResult.getSkipCount()) | ||
- (previousTestResult.getTotalCount() - previousTestResult.getFailCount() - previousTestResult.getSkipCount())); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/hudson/plugins/cigame/rules/unittesting/AbstractSkippedTestsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package hudson.plugins.cigame.rules.unittesting; | ||
|
||
import hudson.plugins.cigame.model.RuleResult; | ||
import hudson.tasks.test.AbstractTestResultAction; | ||
|
||
/** | ||
* Rule that gives points for increasing or decreasing the number of skipped | ||
* tests. This is done by comparing the current with the previous build. | ||
* | ||
* @author <a href="www.digizol.com">Kamal Mettananda</a> | ||
* @since 1.20 | ||
*/ | ||
public abstract class AbstractSkippedTestsRule extends AbstractUnitTestsRule { | ||
|
||
protected abstract RuleResult<Integer> evaluate(int skippedTestDiff); | ||
|
||
@Override | ||
protected RuleResult<Integer> evaluate(AbstractTestResultAction<?> testResult, | ||
AbstractTestResultAction<?> previousTestResult) { | ||
return evaluate(testResult.getSkipCount() - previousTestResult.getSkipCount()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/hudson/plugins/cigame/rules/unittesting/DecreasingFailedTestsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package hudson.plugins.cigame.rules.unittesting; | ||
|
||
import hudson.plugins.cigame.model.RuleResult; | ||
|
||
/** | ||
* Rule that gives points for decreasing the number of failed tests. By default 1 mark given. | ||
* | ||
* @author <a href="www.digizol.com">Kamal Mettananda</a> | ||
* @since 1.20 | ||
*/ | ||
public class DecreasingFailedTestsRule extends AbstractFailedTestsRule { | ||
|
||
private int pointsForDecreasingOneFailedTest; | ||
|
||
public DecreasingFailedTestsRule() { | ||
this(1); | ||
} | ||
|
||
public DecreasingFailedTestsRule(int points) { | ||
pointsForDecreasingOneFailedTest = points; | ||
} | ||
|
||
public String getName() { | ||
return Messages.UnitTestingRuleSet_DecreasingFailedRule_Name(); | ||
} | ||
|
||
@Override | ||
protected String getResultDescription(Integer testDiff) { | ||
return Messages.UnitTestingRuleSet_DecreasingFailedRule_Count(testDiff); | ||
} | ||
|
||
@Override | ||
protected RuleResult<Integer> evaluate(int failedTestDiff) { | ||
if (failedTestDiff < 0) { | ||
failedTestDiff = -failedTestDiff; | ||
return new RuleResult<Integer>(failedTestDiff * pointsForDecreasingOneFailedTest, | ||
Messages.UnitTestingRuleSet_DecreasingFailedRule_Count(failedTestDiff), | ||
failedTestDiff); | ||
} | ||
return null; | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/hudson/plugins/cigame/rules/unittesting/DecreasingPassedTestsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package hudson.plugins.cigame.rules.unittesting; | ||
|
||
import hudson.plugins.cigame.model.RuleResult; | ||
|
||
/** | ||
* Rule that gives points for decreasing the number of passed tests. By default -1 mark given. | ||
* | ||
* @author <a href="www.digizol.com">Kamal Mettananda</a> | ||
* @since 1.20 | ||
*/ | ||
public class DecreasingPassedTestsRule extends AbstractPassedTestsRule { | ||
|
||
private int pointsForDecreasingOnePassingTest; | ||
|
||
public DecreasingPassedTestsRule() { | ||
this(-1); | ||
} | ||
|
||
public DecreasingPassedTestsRule(int points) { | ||
pointsForDecreasingOnePassingTest = points; | ||
} | ||
|
||
public String getName() { | ||
return Messages.UnitTestingRuleSet_DecreasingPassedRule_Name(); | ||
} | ||
|
||
@Override | ||
protected String getResultDescription(Integer testDiff) { | ||
return Messages.UnitTestingRuleSet_DecreasingPassedRule_Count(testDiff); | ||
} | ||
|
||
@Override | ||
protected RuleResult<Integer> evaluate(int passedTestDiff) { | ||
if (passedTestDiff < 0) { | ||
passedTestDiff = -passedTestDiff; | ||
return new RuleResult<Integer>(passedTestDiff * pointsForDecreasingOnePassingTest, | ||
Messages.UnitTestingRuleSet_DecreasingPassedRule_Count(passedTestDiff), | ||
passedTestDiff); | ||
} | ||
return null; | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/hudson/plugins/cigame/rules/unittesting/DecreasingSkippedTestsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package hudson.plugins.cigame.rules.unittesting; | ||
|
||
import hudson.plugins.cigame.model.RuleResult; | ||
|
||
/** | ||
* Rule that gives points for decreasing the number of skipped tests. By default 0 marks given. | ||
* | ||
* @author <a href="www.digizol.com">Kamal Mettananda</a> | ||
* @since 1.20 | ||
*/ | ||
public class DecreasingSkippedTestsRule extends AbstractSkippedTestsRule { | ||
|
||
private int pointsForDecreasingOneSkippedTest; | ||
|
||
public DecreasingSkippedTestsRule() { | ||
this(0); | ||
} | ||
|
||
public DecreasingSkippedTestsRule(int points) { | ||
pointsForDecreasingOneSkippedTest = points; | ||
} | ||
|
||
public String getName() { | ||
return Messages.UnitTestingRuleSet_DecreasingSkippedRule_Name(); | ||
} | ||
|
||
@Override | ||
protected String getResultDescription(Integer testDiff) { | ||
return Messages.UnitTestingRuleSet_DecreasingSkippedRule_Count(testDiff); | ||
} | ||
|
||
@Override | ||
protected RuleResult<Integer> evaluate(int skippedTestDiff) { | ||
if (skippedTestDiff < 0) { | ||
skippedTestDiff = -skippedTestDiff; | ||
return new RuleResult<Integer>(skippedTestDiff * pointsForDecreasingOneSkippedTest, | ||
Messages.UnitTestingRuleSet_DecreasingSkippedRule_Count(skippedTestDiff), | ||
skippedTestDiff); | ||
} | ||
return null; | ||
} | ||
|
||
} |
43 changes: 16 additions & 27 deletions
43
src/main/java/hudson/plugins/cigame/rules/unittesting/IncreasingFailedTestsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,42 @@ | ||
package hudson.plugins.cigame.rules.unittesting; | ||
|
||
import hudson.plugins.cigame.model.RuleResult; | ||
import hudson.tasks.test.AbstractTestResultAction; | ||
|
||
/** | ||
* Rule for giving points if a new test is added and fails. | ||
* Rule for giving points if a test fails (new or existing). By default -1 mark given. | ||
* | ||
* @author Unknown | ||
* @author <a href="www.digizol.com">Kamal Mettananda</a> | ||
* @since 1.20 | ||
*/ | ||
public class IncreasingFailedTestsRule extends AbstractUnitTestsRule { | ||
public class IncreasingFailedTestsRule extends AbstractFailedTestsRule { | ||
|
||
private double pointsForEachNewFailure; | ||
private int pointsForIncreasingOneFailedTest; | ||
|
||
public IncreasingFailedTestsRule() { | ||
this(-1); | ||
} | ||
|
||
public IncreasingFailedTestsRule(int points) { | ||
pointsForEachNewFailure = points; | ||
pointsForIncreasingOneFailedTest = points; | ||
} | ||
|
||
public String getName() { | ||
return Messages.UnitTestingRuleSet_IncreasingFailedRule_Name(); | ||
} | ||
|
||
RuleResult<Integer> evaluate( | ||
int currentFailCount, int previousFailCount) { | ||
int failingTestDiff = currentFailCount - previousFailCount; | ||
@Override | ||
protected String getResultDescription(Integer testDiff) { | ||
return Messages.UnitTestingRuleSet_IncreasingFailedRule_Count(testDiff); | ||
} | ||
|
||
@Override | ||
protected RuleResult<Integer> evaluate(int failingTestDiff) { | ||
if (failingTestDiff > 0) { | ||
return new RuleResult<Integer>(failingTestDiff * pointsForEachNewFailure, | ||
return new RuleResult<Integer>(failingTestDiff * pointsForIncreasingOneFailedTest, | ||
Messages.UnitTestingRuleSet_IncreasingFailedRule_Count(failingTestDiff), | ||
failingTestDiff); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
protected RuleResult evaluate( | ||
AbstractTestResultAction testResult, | ||
AbstractTestResultAction previousTestResult) { | ||
if (testResult == null) { | ||
return null; | ||
} | ||
|
||
return evaluate( | ||
testResult.getFailCount(), previousTestResult.getFailCount()); | ||
} | ||
|
||
@Override | ||
protected String getResultDescription(Integer testDiff) { | ||
return Messages.UnitTestingRuleSet_IncreasingFailedRule_Count(testDiff); | ||
} | ||
} |
67 changes: 22 additions & 45 deletions
67
src/main/java/hudson/plugins/cigame/rules/unittesting/IncreasingPassedTestsRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,43 @@ | ||
package hudson.plugins.cigame.rules.unittesting; | ||
|
||
import hudson.plugins.cigame.model.RuleResult; | ||
import hudson.tasks.test.AbstractTestResultAction; | ||
|
||
/** | ||
* Rule that gives points for increasing the number of passed tests. | ||
* Rule that gives points for increasing the number of passed tests. By default 1 mark given. | ||
* | ||
* @author Unknown | ||
* @author <a href="www.digizol.com">Kamal Mettananda</a> | ||
* @since 1.20 | ||
*/ | ||
public class IncreasingPassedTestsRule extends AbstractUnitTestsRule { | ||
public class IncreasingPassedTestsRule extends AbstractPassedTestsRule { | ||
|
||
private int pointsForEachFixedFailure; | ||
private int pointsForIncreasingOnePassingTest; | ||
|
||
public IncreasingPassedTestsRule() { | ||
this(1); | ||
} | ||
|
||
public IncreasingPassedTestsRule(int points) { | ||
pointsForEachFixedFailure = points; | ||
pointsForIncreasingOnePassingTest = points; | ||
} | ||
|
||
RuleResult<Integer> evaluate( | ||
int currentTotalCount, int currentFailCount, int currentSkipCount, | ||
int previousTotalCount, int previousFailCount, int previousSkipCount) { | ||
|
||
int passedTestDiff = (currentTotalCount - currentFailCount - currentSkipCount) | ||
- (previousTotalCount - previousFailCount - previousSkipCount); | ||
|
||
// ignore any tests which were just 'unskipped' | ||
if (currentSkipCount < previousSkipCount) { | ||
passedTestDiff = passedTestDiff - (previousSkipCount - currentSkipCount); | ||
} | ||
|
||
// passedTestDiff may now be 0 or even negative. Count at least all | ||
// those tests which were fixed | ||
passedTestDiff = Math.max(passedTestDiff, previousFailCount - currentFailCount); | ||
|
||
if (passedTestDiff > 0) { | ||
return new RuleResult<Integer>(passedTestDiff * pointsForEachFixedFailure, | ||
Messages.UnitTestingRuleSet_IncreasingPassedRule_Count(passedTestDiff), | ||
passedTestDiff); | ||
} | ||
return null; | ||
public String getName() { | ||
return Messages.UnitTestingRuleSet_IncreasingPassedRule_Name(); | ||
} | ||
|
||
public String getName() { | ||
return Messages.UnitTestingRuleSet_IncreasingPassedRule_Name(); | ||
@Override | ||
protected String getResultDescription(Integer testDiff) { | ||
return Messages.UnitTestingRuleSet_IncreasingPassedRule_Count(testDiff); | ||
} | ||
|
||
@Override | ||
protected RuleResult<Integer> evaluate( | ||
AbstractTestResultAction<?> testResult, | ||
AbstractTestResultAction<?> previousTestResult) { | ||
if (testResult == null) { | ||
return null; | ||
} | ||
|
||
return evaluate( | ||
testResult.getTotalCount(), testResult.getFailCount(), testResult.getSkipCount(), | ||
previousTestResult.getTotalCount(), previousTestResult.getFailCount(), previousTestResult.getSkipCount()); | ||
} | ||
@Override | ||
protected RuleResult<Integer> evaluate(int passedTestDiff) { | ||
if (passedTestDiff > 0) { | ||
return new RuleResult<Integer>(passedTestDiff * pointsForIncreasingOnePassingTest, | ||
Messages.UnitTestingRuleSet_IncreasingPassedRule_Count(passedTestDiff), | ||
passedTestDiff); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
protected String getResultDescription(Integer testDiff) { | ||
return Messages.UnitTestingRuleSet_IncreasingPassedRule_Count(testDiff); | ||
} | ||
} |
Oops, something went wrong.