Skip to content
Permalink
Browse files

[FIXED JENKINS-6446] Added global configurations for all the six type…

…s of unittest changes (increase or descrease of passed, failed and skipped tests). The configuration is available under 'Continuous integration game - Unit Tests' section in advanced mode. Default values are set to 1 for increasing passing tests, -1 for increasing failed tests and 0 for all other 4 scenarios
  • Loading branch information...
lkamal committed Oct 24, 2013
1 parent e796a32 commit 626af1ccd3ce3eee662f9a567b114c4cc095fdd3
Showing with 303 additions and 91 deletions.
  1. +1 −1 pom.xml
  2. +73 −1 src/main/java/hudson/plugins/cigame/GameDescriptor.java
  3. +8 −9 src/main/java/hudson/plugins/cigame/rules/unittesting/DecreasingFailedTestsRule.java
  4. +8 −9 src/main/java/hudson/plugins/cigame/rules/unittesting/DecreasingPassedTestsRule.java
  5. +8 −9 src/main/java/hudson/plugins/cigame/rules/unittesting/DecreasingSkippedTestsRule.java
  6. +8 −9 src/main/java/hudson/plugins/cigame/rules/unittesting/IncreasingFailedTestsRule.java
  7. +8 −9 src/main/java/hudson/plugins/cigame/rules/unittesting/IncreasingPassedTestsRule.java
  8. +8 −9 src/main/java/hudson/plugins/cigame/rules/unittesting/IncreasingSkippedTestsRule.java
  9. +22 −0 src/main/resources/hudson/plugins/cigame/GamePublisher/global.jelly
  10. +9 −0 src/main/resources/hudson/plugins/cigame/GamePublisher/global.properties
  11. +5 −0 src/main/resources/hudson/plugins/cigame/GamePublisher/help-failedTestDecreasingPoints.html
  12. +5 −0 src/main/resources/hudson/plugins/cigame/GamePublisher/help-failedTestIncreasingPoints.html
  13. +5 −0 src/main/resources/hudson/plugins/cigame/GamePublisher/help-passedTestDecreasingPoints.html
  14. +5 −0 src/main/resources/hudson/plugins/cigame/GamePublisher/help-passedTestIncreasingPoints.html
  15. +5 −0 src/main/resources/hudson/plugins/cigame/GamePublisher/help-skippedTestDecreasingPoints.html
  16. +5 −0 src/main/resources/hudson/plugins/cigame/GamePublisher/help-skippedTestIncreasingPoints.html
  17. +39 −10 src/test/java/hudson/plugins/cigame/rules/unittesting/IncreasingFailedTestsRuleTest.java
  18. +49 −15 src/test/java/hudson/plugins/cigame/rules/unittesting/IncreasingPassedTestsRuleTest.java
  19. +32 −10 src/test/java/hudson/plugins/cigame/rules/unittesting/MavenMultiModuleUnitTestsTest.java
@@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.498</version>
<version>1.499</version>
</parent>

<artifactId>ci-game</artifactId>
@@ -19,6 +19,7 @@
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;

// Config page for the application (descriptor of the game plugin)
@Extension
public class GameDescriptor extends BuildStepDescriptor<Publisher> {

@@ -27,6 +28,13 @@

private transient RuleBook rulebook;
private boolean namesAreCaseSensitive = true;

private int passedTestIncreasingPoints = 1;
private int passedTestDecreasingPoints = 0;
private int failedTestIncreasingPoints = -1;
private int failedTestDecreasingPoints = 0;
private int skippedTestIncreasingPoints = 0;
private int skippedTestDecreasingPoints = 0;

public GameDescriptor() {
super(GamePublisher.class);
@@ -60,24 +68,27 @@ private void addRuleSetIfAvailable(RuleBook book, RuleSet ruleSet) {
}
}

// config page heading
@Override
public String getDisplayName() {
return Messages.Plugin_Title();
}

// creates a instance with form data; but this only creates empty new object
@Override
public GamePublisher newInstance(StaplerRequest req, JSONObject formData)
throws hudson.model.Descriptor.FormException {
return new GamePublisher();
}

// invoked when even properties are updated (global properties configured with global.jelly
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
req.bindJSON(this, json);
save();
return true;
}

public boolean getNamesAreCaseSensitive() {
return namesAreCaseSensitive;
}
@@ -90,4 +101,65 @@ public void setNamesAreCaseSensitive(boolean namesAreCaseSensitive) {
public boolean isApplicable(Class<? extends AbstractProject> arg0) {
return true;
}


public int getPassedTestIncreasingPoints() {
return passedTestIncreasingPoints;
}


public void setPassedTestIncreasingPoints(int passedTestIncreasingPoints) {
this.passedTestIncreasingPoints = passedTestIncreasingPoints;
}


public int getPassedTestDecreasingPoints() {
return passedTestDecreasingPoints;
}


public void setPassedTestDecreasingPoints(int passedTestDecreasingPoints) {
this.passedTestDecreasingPoints = passedTestDecreasingPoints;
}


public int getFailedTestIncreasingPoints() {
return failedTestIncreasingPoints;
}


public void setFailedTestIncreasingPoints(int failedTestIncreasingPoints) {
this.failedTestIncreasingPoints = failedTestIncreasingPoints;
}


public int getFailedTestDecreasingPoints() {
return failedTestDecreasingPoints;
}


public void setFailedTestDecreasingPoints(int failedTestDecreasingPoints) {
this.failedTestDecreasingPoints = failedTestDecreasingPoints;
}


public int getSkippedTestIncreasingPoints() {
return skippedTestIncreasingPoints;
}


public void setSkippedTestIncreasingPoints(int skippedTestIncreasingPoints) {
this.skippedTestIncreasingPoints = skippedTestIncreasingPoints;
}


public int getSkippedTestDecreasingPoints() {
return skippedTestDecreasingPoints;
}


public void setSkippedTestDecreasingPoints(int skippedTestDecreasingPoints) {
this.skippedTestDecreasingPoints = skippedTestDecreasingPoints;
}

}
@@ -1,23 +1,22 @@
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 1 mark given.
* 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 int pointsForDecreasingOneFailedTest;
private static final int DEFAULT_POINTS = 0;

public DecreasingFailedTestsRule() {
this(1);
}

public DecreasingFailedTestsRule(int points) {
pointsForDecreasingOneFailedTest = points;
private int getPoints() {
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
return gameDescriptor!=null?gameDescriptor.getFailedTestDecreasingPoints():DEFAULT_POINTS;
}

public String getName() {
@@ -33,7 +32,7 @@ protected String getResultDescription(Integer testDiff) {
protected RuleResult<Integer> evaluate(int failedTestDiff) {
if (failedTestDiff < 0) {
failedTestDiff = -failedTestDiff;
return new RuleResult<Integer>(failedTestDiff * pointsForDecreasingOneFailedTest,
return new RuleResult<Integer>(failedTestDiff * getPoints(),
Messages.UnitTestingRuleSet_DecreasingFailedRule_Count(failedTestDiff),
failedTestDiff);
}
@@ -1,5 +1,7 @@
package hudson.plugins.cigame.rules.unittesting;

import jenkins.model.Jenkins;
import hudson.plugins.cigame.GameDescriptor;
import hudson.plugins.cigame.model.RuleResult;

/**
@@ -10,16 +12,13 @@
*/
public class DecreasingPassedTestsRule extends AbstractPassedTestsRule {

private int pointsForDecreasingOnePassingTest;
private static final int DEFAULT_POINTS = 1;

public DecreasingPassedTestsRule() {
this(-1);
private int getPoints() {
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
return gameDescriptor!=null?gameDescriptor.getPassedTestDecreasingPoints():DEFAULT_POINTS;
}

public DecreasingPassedTestsRule(int points) {
pointsForDecreasingOnePassingTest = points;
}


public String getName() {
return Messages.UnitTestingRuleSet_DecreasingPassedRule_Name();
}
@@ -33,7 +32,7 @@ protected String getResultDescription(Integer testDiff) {
protected RuleResult<Integer> evaluate(int passedTestDiff) {
if (passedTestDiff < 0) {
passedTestDiff = -passedTestDiff;
return new RuleResult<Integer>(passedTestDiff * pointsForDecreasingOnePassingTest,
return new RuleResult<Integer>(passedTestDiff * getPoints(),
Messages.UnitTestingRuleSet_DecreasingPassedRule_Count(passedTestDiff),
passedTestDiff);
}
@@ -1,5 +1,7 @@
package hudson.plugins.cigame.rules.unittesting;

import jenkins.model.Jenkins;
import hudson.plugins.cigame.GameDescriptor;
import hudson.plugins.cigame.model.RuleResult;

/**
@@ -10,16 +12,13 @@
*/
public class DecreasingSkippedTestsRule extends AbstractSkippedTestsRule {

private int pointsForDecreasingOneSkippedTest;
private static final int DEFAULT_POINTS = 0;

public DecreasingSkippedTestsRule() {
this(0);
private int getPoints() {
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
return gameDescriptor!=null?gameDescriptor.getSkippedTestDecreasingPoints():DEFAULT_POINTS;
}

public DecreasingSkippedTestsRule(int points) {
pointsForDecreasingOneSkippedTest = points;
}


public String getName() {
return Messages.UnitTestingRuleSet_DecreasingSkippedRule_Name();
}
@@ -33,7 +32,7 @@ protected String getResultDescription(Integer testDiff) {
protected RuleResult<Integer> evaluate(int skippedTestDiff) {
if (skippedTestDiff < 0) {
skippedTestDiff = -skippedTestDiff;
return new RuleResult<Integer>(skippedTestDiff * pointsForDecreasingOneSkippedTest,
return new RuleResult<Integer>(skippedTestDiff * getPoints(),
Messages.UnitTestingRuleSet_DecreasingSkippedRule_Count(skippedTestDiff),
skippedTestDiff);
}
@@ -1,5 +1,7 @@
package hudson.plugins.cigame.rules.unittesting;

import jenkins.model.Jenkins;
import hudson.plugins.cigame.GameDescriptor;
import hudson.plugins.cigame.model.RuleResult;

/**
@@ -11,16 +13,13 @@
*/
public class IncreasingFailedTestsRule extends AbstractFailedTestsRule {

private int pointsForIncreasingOneFailedTest;
private static final int DEFAULT_POINTS = -1;

public IncreasingFailedTestsRule() {
this(-1);
private int getPoints() {
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
return gameDescriptor!=null?gameDescriptor.getFailedTestIncreasingPoints():DEFAULT_POINTS;
}

public IncreasingFailedTestsRule(int points) {
pointsForIncreasingOneFailedTest = points;
}


public String getName() {
return Messages.UnitTestingRuleSet_IncreasingFailedRule_Name();
}
@@ -33,7 +32,7 @@ protected String getResultDescription(Integer testDiff) {
@Override
protected RuleResult<Integer> evaluate(int failingTestDiff) {
if (failingTestDiff > 0) {
return new RuleResult<Integer>(failingTestDiff * pointsForIncreasingOneFailedTest,
return new RuleResult<Integer>(failingTestDiff * getPoints(),
Messages.UnitTestingRuleSet_IncreasingFailedRule_Count(failingTestDiff),
failingTestDiff);
}
@@ -1,6 +1,8 @@
package hudson.plugins.cigame.rules.unittesting;

import hudson.plugins.cigame.GameDescriptor;
import hudson.plugins.cigame.model.RuleResult;
import jenkins.model.Jenkins;

/**
* Rule that gives points for increasing the number of passed tests. By default 1 mark given.
@@ -11,16 +13,13 @@
*/
public class IncreasingPassedTestsRule extends AbstractPassedTestsRule {

private int pointsForIncreasingOnePassingTest;
private static final int DEFAULT_POINTS = 1;

public IncreasingPassedTestsRule() {
this(1);
private int getPoints() {
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
return gameDescriptor!=null?gameDescriptor.getPassedTestIncreasingPoints():DEFAULT_POINTS;
}

public IncreasingPassedTestsRule(int points) {
pointsForIncreasingOnePassingTest = points;
}


public String getName() {
return Messages.UnitTestingRuleSet_IncreasingPassedRule_Name();
}
@@ -33,7 +32,7 @@ protected String getResultDescription(Integer testDiff) {
@Override
protected RuleResult<Integer> evaluate(int passedTestDiff) {
if (passedTestDiff > 0) {
return new RuleResult<Integer>(passedTestDiff * pointsForIncreasingOnePassingTest,
return new RuleResult<Integer>(passedTestDiff * getPoints(),
Messages.UnitTestingRuleSet_IncreasingPassedRule_Count(passedTestDiff),
passedTestDiff);
}
@@ -1,5 +1,7 @@
package hudson.plugins.cigame.rules.unittesting;

import jenkins.model.Jenkins;
import hudson.plugins.cigame.GameDescriptor;
import hudson.plugins.cigame.model.RuleResult;

/**
@@ -10,16 +12,13 @@
*/
public class IncreasingSkippedTestsRule extends AbstractSkippedTestsRule {

private int pointsForIncreasingOneSkippedTest;
private static final int DEFAULT_POINTS = 0;

public IncreasingSkippedTestsRule() {
this(0);
private int getPoints() {
GameDescriptor gameDescriptor = Jenkins.getInstance().getDescriptorByType(GameDescriptor.class);
return gameDescriptor!=null?gameDescriptor.getSkippedTestIncreasingPoints():DEFAULT_POINTS;
}

public IncreasingSkippedTestsRule(int points) {
pointsForIncreasingOneSkippedTest = points;
}


public String getName() {
return Messages.UnitTestingRuleSet_IncreasingSkippedRule_Name();
}
@@ -32,7 +31,7 @@ protected String getResultDescription(Integer testDiff) {
@Override
protected RuleResult<Integer> evaluate(int passedTestDiff) {
if (passedTestDiff > 0) {
return new RuleResult<Integer>(passedTestDiff * pointsForIncreasingOneSkippedTest,
return new RuleResult<Integer>(passedTestDiff * getPoints(),
Messages.UnitTestingRuleSet_IncreasingSkippedRule_Count(passedTestDiff),
passedTestDiff);
}
@@ -5,4 +5,26 @@
<f:checkbox field="namesAreCaseSensitive"/>
</f:entry>
</f:section>
<f:section title="${%cigame.title} - ${%cigame.unittests.subtitle}">
<f:advanced>
<f:entry title="${%cigame.unittests.marksForIncreasingPassedTestsByOne}" field="passedTestIncreasingPoints">
<f:textbox/>
</f:entry>
<f:entry title="${%cigame.unittests.marksForDecreasingPassedTestsByOne}" field="passedTestDecreasingPoints">
<f:textbox/>
</f:entry>
<f:entry title="${%cigame.unittests.marksForIncreasingFailedTestsByOne}" field="failedTestIncreasingPoints">
<f:textbox/>
</f:entry>
<f:entry title="${%cigame.unittests.marksForDecreasingFailedTestsByOne}" field="failedTestDecreasingPoints">
<f:textbox/>
</f:entry>
<f:entry title="${%cigame.unittests.marksForIncreasingSkippedTestsByOne}" field="skippedTestIncreasingPoints">
<f:textbox/>
</f:entry>
<f:entry title="${%cigame.unittests.marksForDecreasingSkippedTestsByOne}" field="skippedTestDecreasingPoints">
<f:textbox/>
</f:entry>
</f:advanced>
</f:section>
</j:jelly>
Oops, something went wrong.

0 comments on commit 626af1c

Please sign in to comment.
You can’t perform that action at this time.