Skip to content

Commit

Permalink
Add support for healthScaleFactor in JUnit Plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dónal Adams committed Oct 4, 2016
1 parent 2676d6e commit e875227
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ job('example-2') {
archiveJunit('**/minitest-reports/*.xml') {
allowEmptyResults()
retainLongStdout()
healthScaleFactor()
testDataPublishers {
publishTestStabilityData()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ArchiveJUnitContext extends AbstractContext {
final TestDataPublishersContext testDataPublishersContext
boolean allowEmptyResults
boolean retainLongStdout
double healthScaleFactor = 1.0

ArchiveJUnitContext(JobManagement jobManagement) {
super(jobManagement)
Expand All @@ -32,6 +33,16 @@ class ArchiveJUnitContext extends AbstractContext {
retainLongStdout = retain
}

/**
* The amplification factor to apply to test failures when computing the test result contribution to the
* build health score.
* The default factor is {@code 1.0}.
* @param factor
*/
void healthScaleFactor(double factor = 1.0) {
healthScaleFactor = factor
}

/**
* Adds additional test report features provided by other Jenkins plugins.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class PublisherContext extends AbstractExtensibleContext {
keepLongStdio(junitContext.retainLongStdout)
testDataPublishers(junitContext.testDataPublishersContext.testDataPublishers)
allowEmptyResults(junitContext.allowEmptyResults)
healthScaleFactor(junitContext.healthScaleFactor)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ class PublisherContextSpec extends Specification {
context.archiveJunit('include/*') {
allowEmptyResults()
retainLongStdout()
healthScaleFactor()
testDataPublishers {
allowClaimingOfFailedTests()
publishTestAttachments()
Expand All @@ -356,10 +357,11 @@ class PublisherContextSpec extends Specification {
then:
with(context.publisherNodes[0]) {
name() == 'hudson.tasks.junit.JUnitResultArchiver'
children().size() == 4
children().size() == 5
testResults[0].value() == 'include/*'
allowEmptyResults[0].value() == true
keepLongStdio[0].value() == true
healthScaleFactor[0].value() == 1.0
testDataPublishers[0].children().size() == 4
testDataPublishers[0].'hudson.plugins.claim.ClaimTestDataPublisher'[0] != null
testDataPublishers[0].'hudson.plugins.junitattachments.AttachmentPublisher'[0] != null
Expand All @@ -381,10 +383,11 @@ class PublisherContextSpec extends Specification {
then:
with(context.publisherNodes[0]) {
name() == 'hudson.tasks.junit.JUnitResultArchiver'
children().size() == 4
children().size() == 5
testResults[0].value() == 'include/*'
keepLongStdio[0].value() == false
allowEmptyResults[0].value() == false
healthScaleFactor[0].value() == 1.0
testDataPublishers[0].children().size() == 0
}
1 * jobManagement.requireMinimumPluginVersion('junit', '1.10')
Expand Down

0 comments on commit e875227

Please sign in to comment.