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
Merge pull request #11 from lkamal/master
[FIXED JENKINS-6446] added global configurations for all the six types of unittest changes (increase or descrease of passed, failed and skipped tests)
- Loading branch information
Showing
27 changed files
with
597 additions
and
310 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
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
42 changes: 42 additions & 0 deletions
42
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,42 @@ | ||
package hudson.plugins.cigame.rules.unittesting; | ||
|
||
import jenkins.model.Jenkins; | ||
import hudson.plugins.cigame.GameDescriptor; | ||
import hudson.plugins.cigame.model.RuleResult; | ||
|
||
/** | ||
* Rule that gives points for decreasing the number of failed tests. By default 0 mark given. | ||
* | ||
* @author <a href="www.digizol.com">Kamal Mettananda</a> | ||
* @since 1.20 | ||
*/ | ||
public class DecreasingFailedTestsRule extends AbstractFailedTestsRule { | ||
|
||
private static final int DEFAULT_POINTS = 0; | ||
|
||
private int getPoints() { | ||
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class); | ||
return gameDescriptor!=null?gameDescriptor.getFailedTestDecreasingPoints():DEFAULT_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 * getPoints(), | ||
Messages.UnitTestingRuleSet_DecreasingFailedRule_Count(failedTestDiff), | ||
failedTestDiff); | ||
} | ||
return null; | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
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,42 @@ | ||
package hudson.plugins.cigame.rules.unittesting; | ||
|
||
import jenkins.model.Jenkins; | ||
import hudson.plugins.cigame.GameDescriptor; | ||
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 static final int DEFAULT_POINTS = 1; | ||
|
||
private int getPoints() { | ||
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class); | ||
return gameDescriptor!=null?gameDescriptor.getPassedTestDecreasingPoints():DEFAULT_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 * getPoints(), | ||
Messages.UnitTestingRuleSet_DecreasingPassedRule_Count(passedTestDiff), | ||
passedTestDiff); | ||
} | ||
return null; | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
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,42 @@ | ||
package hudson.plugins.cigame.rules.unittesting; | ||
|
||
import jenkins.model.Jenkins; | ||
import hudson.plugins.cigame.GameDescriptor; | ||
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 static final int DEFAULT_POINTS = 0; | ||
|
||
private int getPoints() { | ||
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class); | ||
return gameDescriptor!=null?gameDescriptor.getSkippedTestDecreasingPoints():DEFAULT_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 * getPoints(), | ||
Messages.UnitTestingRuleSet_DecreasingSkippedRule_Count(skippedTestDiff), | ||
skippedTestDiff); | ||
} | ||
return null; | ||
} | ||
|
||
} |
Oops, something went wrong.