Skip to content

Commit

Permalink
Feature/id in test cycle results (#638)
Browse files Browse the repository at this point in the history
* Change the way the test cycle name is created

* Change message

* Unit test

* Add changelog entry

* Fix codenarc violations
  • Loading branch information
jorge-romero authored May 3, 2021
1 parent f5dcea5 commit 007c8a6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Fixed the Document History of the IVP & IVR is not being generated ([#627](https://github.com/opendevstack/ods-jenkins-shared-library/pull/627))
- Fixed Test name/summary in DTP/DTR documents ([#625](https://github.com/opendevstack/ods-jenkins-shared-library/pull/625)).
- Fix A "null" string is added in the Section 3.1 of the CFTR when the Description of the Zephyr Unit Test doesn't has a Description ([#634](https://github.com/opendevstack/ods-jenkins-shared-library/pull/634))
- Change association with the current release in the test cycles of previewed execution ([#638](https://github.com/opendevstack/ods-jenkins-shared-library/pull/638))

## [3.0] - 2020-08-11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.ods.util.IPipelineSteps
import org.ods.orchestration.util.MROPipelineUtil
import org.ods.orchestration.util.Project

@SuppressWarnings(['IfStatementBraces', 'LineLength', 'AbcMetric', 'Instanceof'])
@SuppressWarnings(['IfStatementBraces', 'LineLength', 'AbcMetric', 'Instanceof', 'CyclomaticComplexity'])
class JiraUseCaseZephyrSupport extends AbstractJiraUseCaseSupport {

private JiraZephyrService zephyr
Expand All @@ -26,15 +26,16 @@ class JiraUseCaseZephyrSupport extends AbstractJiraUseCaseSupport {
if (!testIssues?.isEmpty()) {
def buildParams = this.project.buildParams

def versionId = this.project.version?.id ?: '-1'
def versionId = this.project.version?.id ?: project.loadVersionDataFromJira(buildParams.changeId)?.id
def testCycles = this.zephyr.getTestCycles(this.project.id, versionId)

// Zephyr test cycle properties
def name = buildParams.targetEnvironmentToken + ': Build ' + this.steps.env.BUILD_ID
def name = (buildParams.version == 'WIP'? "Preview: Build ": "${buildParams.targetEnvironmentToken}: Build ") + this.steps.env.BUILD_ID
def build = this.steps.env.BUILD_URL
def environment = buildParams.targetEnvironment

testCycleId = testCycles.find { it.value instanceof Map && it.value.name == name && it.value.build == build && it.value.environment == environment }?.key

if (!testCycleId) {
testCycleId = this.zephyr.createTestCycle(this.project.id, versionId, name, build, environment).id
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/ods/orchestration/util/Project.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ class Project {
loadVersionDataFromJira(this.buildParams.version)
}

protected Map loadVersionDataFromJira(String versionName) {
Map loadVersionDataFromJira(String versionName) {
if (!this.jiraUseCase) return [:]
if (!this.jiraUseCase.jira) return [:]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,18 @@ class JiraUseCaseZephyrSupportSpec extends SpecHelper {
_ * zephyr.createTestExecutionForIssue(*_) >> ["1": []]
1 * support.applyXunitTestResultsAsTestExecutionStatii(testIssues, testResults)
}

def "generate test cycle for developer previews"() {
given:
def testIssues = createJiraTestIssues()
def testResults = createTestResults()
project.buildParams.version = 'WIP'

when:
support.applyXunitTestResultsAsTestExecutionStatii(testIssues, testResults)

then:
1 * zephyr.createTestCycle(project.id, "11100", "Preview: Build " + steps.env.BUILD_ID, steps.env.BUILD_URL, project.buildParams.targetEnvironment) >> [id: "111"]
_ * zephyr.createTestExecutionForIssue(*_) >> ["1": []]
}
}

0 comments on commit 007c8a6

Please sign in to comment.