Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for healthScaleFactor in JUnit Plugin. #928

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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