Skip to content

Commit

Permalink
XCP-5 Adding options to skip updating failed case (#5)
Browse files Browse the repository at this point in the history
* XCP-5 Adding options to skip updating failed case

* XCP-5 Fixing Lint

Co-authored-by: Tamil Natesan <[email protected]>
  • Loading branch information
tamil777selvan and Tamil-Natesan authored Jul 19, 2022
1 parent 9830d0b commit ca3aefe
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,11 @@ XrayCucumberPlugin.updateTestExecutionResults(options);
| testExecutionIds | List of Xray Test Execution Id's to which result needs to be updated |
| cucumberJsonReportFolder | Root folder path where the cucumber JSON report is stored |
| parsedTestResultDetails | Update test execution results based on custom formed result list. Structure can be found [here](#structure-of-parsedTestResultDetails) |
| skipUpdatingFailedCase | Skip the updation of failed test cases to the corresponding test execution tickets |

**Note :** Always try to keep the `${cucumberJsonReportFolder}` folder clean before test execution by clearing old unwanted reports. Else, there can be a flakiness in the output.
**Note :**
- Always try to keep the `${cucumberJsonReportFolder}` folder clean before test execution by clearing old unwanted reports. Else, there can be a flakiness in the output.
- The array list passed in `${parsedTestResultDetails}` takes precedence over `${cucumberJsonReportFolder}`. So, if you wish to update results from Cucumber JSON, try avoiding adding `${parsedTestResultDetails}` to the input param.

## Default Options

Expand All @@ -191,6 +194,7 @@ XrayCucumberPlugin.updateTestExecutionResults(options);
| jiraUsername | process.env.JIRA_USERNAME |
| jiraPassword | process.env.JIRA_PASSWORD |
| parsedTestResultDetails | undefined |
| skipUpdatingFailedCase | false |

**Note :** Passing options via the `updateTestExecutionResults` function takes precedence and overrides the default values.

Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export default {
const defaults = {
jiraUsername: process.env.JIRA_USERNAME,
jiraPassword: process.env.JIRA_PASSWORD,
parsedTestResultDetails: undefined
parsedTestResultDetails: undefined,
skipUpdatingFailedCase: false
}

const inputOptions = {
Expand Down
7 changes: 6 additions & 1 deletion src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,10 @@ export interface TestExecutionResults {
* Parsed tests result details list
* @default undefined
*/
parsedTestResultDetails?: string[]
parsedTestResultDetails?: string[],
/**
* Skip updating execution tickets for failed test cases
* @default false
*/
skipUpdatingFailedCase?: boolean
}
4 changes: 4 additions & 0 deletions src/updateTestExecutionResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export const updateTestExecutionResults = async (options: TestExecutionResults)
testDetails = await parseCucumberReports(options.cucumberJsonReportFolder);
}

if (options.skipUpdatingFailedCase) {
testDetails = _.remove(testDetails, (val) => _.lowerCase(_.values(val).toString()) !== 'fail' );
}

// Get all tickets
const existingTickets = _.remove(await getExistingTickets(options.jiraHost, options.jiraProject, options.xrayScenarioType.id, options.xrayStepId, options.headers));
const optimisedExistingTickets = existingTickets.map((ticket) => {
Expand Down

0 comments on commit ca3aefe

Please sign in to comment.