-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing try catch for execution and publishing in AzureTestPlanV0 (
#19748) * Implementing try catch for execution and publishing * Adding Promise to applicable places * Upgrading Task Version * Removing extra lines * Addressing comments --------- Co-authored-by: triptijain2112 <92331194+triptijain2112@users.noreply.github.com>
- Loading branch information
1 parent
fd95edd
commit f113906
Showing
31 changed files
with
376 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
import tl = require('azure-pipelines-task-lib/task'); | ||
import { testInvoker } from './automatedTestInvoker' | ||
import { TestPlanData } from './testPlanData' | ||
import { publishAutomatedTestResult } from './publishAutomatedTests' | ||
import { testInvoker } from './automatedTestInvoker'; | ||
import { TestPlanData } from './testPlanData'; | ||
import { publishAutomatedTestResult } from './publishAutomatedTests'; | ||
|
||
export async function automatedTestsFlow(testPlanInfo: TestPlanData, testSelectorInput: string): Promise<number> { | ||
let listOfTestsToBeExecuted: string[] = testPlanInfo.listOfFQNOfTestCases; | ||
let testInvokerStatusCode = 0; | ||
|
||
export async function automatedTestsFlow(testPlanInfo: TestPlanData, testSelectorInput: string) { | ||
if (listOfTestsToBeExecuted !== null && listOfTestsToBeExecuted !== undefined && listOfTestsToBeExecuted.length > 0) { | ||
tl.debug('Invoking test execution for tests: ' + listOfTestsToBeExecuted); | ||
|
||
let listOfTestsToBeExecuted: string[] = testPlanInfo.listOfFQNOfTestCases; | ||
|
||
console.log(tl.loc('automatedTestTriggered')); | ||
|
||
if (listOfTestsToBeExecuted !== null && listOfTestsToBeExecuted !== undefined && listOfTestsToBeExecuted.length > 0) { | ||
tl.debug("Invoking test execution for tests: " + listOfTestsToBeExecuted); | ||
await testInvoker(listOfTestsToBeExecuted); | ||
publishAutomatedTestResult(JSON.stringify(testPlanInfo.listOfAutomatedTestPoints)); | ||
try { | ||
testInvokerStatusCode = await testInvoker(listOfTestsToBeExecuted); | ||
} catch (err) { | ||
tl.debug(`Unable to invoke automated test execution. Err:( ${err} )`); | ||
testInvokerStatusCode = 1; | ||
} | ||
else { | ||
console.log("No automated tests found for given test plan inputs "); | ||
if (testSelectorInput === 'automatedTests') { | ||
tl.setResult(tl.TaskResult.Failed, tl.loc('ErrorFailTaskOnNoAutomatedTestsFound')); | ||
} | ||
else { | ||
tl.setResult(tl.TaskResult.Succeeded, "Successfully triggered manual test execution"); | ||
} | ||
|
||
try { | ||
await publishAutomatedTestResult(JSON.stringify(testPlanInfo.listOfAutomatedTestPoints)); | ||
} catch (err) { | ||
tl.error(`Error while publishing automated Test Results with err : ( ${err} )`); | ||
return 1; | ||
} | ||
|
||
tl.debug(`Execution Status Code for test Invoker: ${testInvokerStatusCode}`); | ||
return testInvokerStatusCode; | ||
} else { | ||
console.log('No automated tests found for given test plan inputs '); | ||
if (testSelectorInput === 'automatedTests') { | ||
tl.setResult(tl.TaskResult.Failed, tl.loc('ErrorFailTaskOnNoAutomatedTestsFound')); | ||
return 1; | ||
} else { | ||
tl.setResult(tl.TaskResult.Succeeded, 'Successfully triggered manual test execution'); | ||
return 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
import tl = require('azure-pipelines-task-lib/task'); | ||
import { TestPlanData, createManualTestRun, ManualTestRunData } from './testPlanData'; | ||
|
||
export async function manualTestsFlow(testPlanInfo: TestPlanData) { | ||
export async function manualTestsFlow(testPlanInfo: TestPlanData):Promise<number> { | ||
|
||
let manualTestRun: ManualTestRunData = { testRunId: 0, runUrl: "" }; | ||
|
||
manualTestRun = await createManualTestRun(testPlanInfo); | ||
|
||
try{ | ||
manualTestRun = await createManualTestRun(testPlanInfo); | ||
} | ||
catch (err){ | ||
tl.debug(`Unable to create Manual Test Run. Err:( ${err} )`); | ||
return 1; | ||
} | ||
|
||
console.log('Test run id created: ', manualTestRun.testRunId); | ||
console.log('Test run url: ', manualTestRun.runUrl); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
"version": { | ||
"Major": 0, | ||
"Minor": 238, | ||
"Patch": 6 | ||
"Patch": 8 | ||
}, | ||
"preview": true, | ||
"demands": [], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
"version": { | ||
"Major": 0, | ||
"Minor": 238, | ||
"Patch": 6 | ||
"Patch": 8 | ||
}, | ||
"preview": true, | ||
"demands": [], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Default|0.238.6 | ||
Node20-225|0.238.7 | ||
Default|0.238.8 | ||
Node20-225|0.238.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.