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

New Azure Test plan task #19440

Merged
merged 38 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cddddb2
created new PR
triptijain2112 Jan 11, 2024
e724a61
updated package.json
triptijain2112 Jan 11, 2024
3e3842f
updating packages file
triptijain2112 Jan 11, 2024
8607d83
Merge branch 'master' into users/triptijain/TestPlanNewTask
triptijain2112 Jan 11, 2024
c7d872c
Merge branch 'master' into users/triptijain/TestPlanNewTask
triptijain2112 Jan 11, 2024
b117374
updated commit with retrieval logic
triptijain2112 Jan 16, 2024
8b99861
Merge branch 'users/triptijain/TestPlanNewTask' of https://github.com…
triptijain2112 Jan 16, 2024
9537693
Merge branch 'master' into users/triptijain/TestPlanNewTask
triptijain2112 Jan 16, 2024
11220d6
rebuilt local
triptijain2112 Jan 16, 2024
ff092b8
Merge branch 'users/triptijain/TestPlanNewTask' of https://github.com…
triptijain2112 Jan 16, 2024
bbbcb4d
updated api call method name
triptijain2112 Jan 17, 2024
a05335b
Merge branch 'master' into users/triptijain/TestPlanNewTask
triptijain2112 Jan 17, 2024
9c4742c
added sample command and removed sleep statement
triptijain2112 Jan 17, 2024
bb62196
updated icon
triptijain2112 Jan 17, 2024
37076c5
Merge branch 'master' into users/triptijain/TestPlanNewTask
triptijain2112 Jan 17, 2024
fc3861b
updated task description
triptijain2112 Jan 17, 2024
df19298
Merge branch 'users/triptijain/TestPlanNewTask' of https://github.com…
triptijain2112 Jan 17, 2024
8dfd1af
updated logic for selecting tests
triptijain2112 Jan 18, 2024
f232664
Updated error message
triptijain2112 Jan 18, 2024
ef0cdc5
added null check
triptijain2112 Jan 18, 2024
e931db2
removed -v from python invoker
triptijain2112 Jan 18, 2024
74c58ae
updated resources file
triptijain2112 Jan 18, 2024
ba34c2b
updated task fail logic
triptijain2112 Jan 19, 2024
5e3aea0
updated task fail condition
triptijain2112 Jan 19, 2024
ca8ee4c
updated task name
triptijain2112 Jan 20, 2024
9c758e6
updated
triptijain2112 Jan 20, 2024
3e9ce09
updated deleted files
triptijain2112 Jan 20, 2024
cf3bdb6
added utils file
triptijain2112 Jan 20, 2024
183476a
added constants file and console.error
triptijain2112 Jan 21, 2024
a0c3bb0
added public doc link
triptijain2112 Jan 21, 2024
c30b1a9
added task failre on api failure
triptijain2112 Jan 21, 2024
c192f2d
updated if condition
triptijain2112 Jan 21, 2024
23cf29a
updated error scenario
triptijain2112 Jan 22, 2024
0a27857
Merge branch 'master' into users/triptijain/TestPlanNewTask
triptijain2112 Jan 23, 2024
dfcb953
review comments update
triptijain2112 Jan 23, 2024
567d9bd
Merge branch 'users/triptijain/TestPlanNewTask' of https://github.com…
triptijain2112 Jan 23, 2024
8babf14
updated indentation
triptijain2112 Jan 23, 2024
6eea26d
added null checks
triptijain2112 Jan 23, 2024
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ Tasks/AzureSpringCloudV0 @microsoft/azure-spring-apps @ruoyuwang @menxiao

Tasks/AzureStaticWebAppV0/ @microsoft/azure-static-web-apps @mkarmark @joslinmicrosoft

Tasks/AzureTestPlanV0/ @rasunkar @microsoft\adoautotest

Tasks/AzureWebAppV1/ @vsebesta @rvairavelu @pipeline-environment-team

Tasks/AzureWebAppContainerV1/ @vsebesta @rvairavelu @pipeline-environment-team
Expand Down
31 changes: 31 additions & 0 deletions Tasks/AzureTestPlanV0/Invokers/gradleinvoker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { spawn } from '../testexecutor'
import tl = require('azure-pipelines-task-lib/task');
import utils = require('../utils');
import constants = require('../constants');
export async function executegradletests(testsToBeExecuted: string[]) {

//public doc link: https://docs.gradle.org/current/userguide/command_line_interface.html
//gradle command like "gradle test --tests=<package.className.testName> --tests=<package.className.testName>"

const executable = constants.GRADLE_EXECUTABLE;
const args = []

args.push('test');

for (let testcase of testsToBeExecuted) {

// in some cases found that gradle is including () in test name
utils.removeParenthesesFromEnd(testcase);
args.push('--tests=' + testcase);
}

tl.debug("Executing gradle tests with executable : " + executable);
tl.debug("Executing gradle tests with args :" + args);

const { status, error } = await spawn(executable, args)
if (error) {
tl.error("Error executing gradle command, " + error);
}

return { exitCode: status ?? 1 }
}
39 changes: 39 additions & 0 deletions Tasks/AzureTestPlanV0/Invokers/maveninvoker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { spawn } from '../testexecutor'
import tl = require('azure-pipelines-task-lib/task');
import utils = require('../utils');
import constants = require('../constants');

export async function executemaventests(testsToBeExecuted: string[]) {

//public doc link: https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html
//maven command like "mvn test -Dtest=<package.className#testName>,<package.className#testName1>"

const executable = constants.MVN_EXECUTABLE;
const args = []
const testsToRun =[]

for (let tests of testsToBeExecuted) {
const modifiedTest = utils.replaceLastDotWithHash(tests);
testsToRun.push(modifiedTest);
}

if (testsToRun.length > 0)
{
const testsList = testsToRun.join(',')
const dtest = constants.MAVEN_DTEST;
const newArgs = dtest + testsList;

args.push('test');
args.push(newArgs);
}

tl.debug("Executing java maven tests with executable : " + executable);
tl.debug("Executing java maven tests with args :" + args);

const { status, error } = await spawn(executable, args)
if (error) {
tl.error("Error executing mvn command, " + error);
}

return { exitCode: status ?? 1 }
}
29 changes: 29 additions & 0 deletions Tasks/AzureTestPlanV0/Invokers/pythonivoker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { spawn } from '../testexecutor'
import tl = require('azure-pipelines-task-lib/task');
import constants = require('../constants');

export async function executepythontests(testsToBeExecuted: string[]) {

//public doc link: https://docs.pytest.org/en/7.1.x/how-to/usage.html#specifying-which-tests-to-run
//pytest command like "pytest -v <package.className.testName1> <package.className.testName2> --junitxml=junit.xml"

const executable = constants.PYTEST_EXECUTABLE;
let args: string[] = [];

for (let testcase of testsToBeExecuted) {
args.push(testcase);
}

args.push('--junitxml=junit.xml')

tl.debug("Executing python tests with executable : " + executable);
tl.debug("Executing python tests with args :" + args);

const { status, error } = await spawn(executable, args)

if (error) {
tl.error("Error executing pytest command, " + error);
}

return { exitCode: status ?? 1 }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"loc.friendlyName": "Azure Test Plan",
"loc.helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?LinkID=613742)",
"loc.description": "Run manual and automated tests in test plan in Java and python language",
"loc.instanceNameFormat": "Azure Test Plan - $(testSelector)",
"loc.input.label.testSelector": "Test cases to be executed",
"loc.input.help.testSelector": "<ul><li><b>Manual tests: </b>Use this option to trigger manual tests from your test plan.</li><li><b>Automated tests: </b>Use this option to run tests from your test plan that have automated test method associated with it.</li>",
"loc.input.label.testPlan": "Test plan",
"loc.input.help.testPlan": "Select a test plan containing test suites with test cases.",
"loc.input.label.testSuite": "Test suite",
"loc.input.help.testSuite": "Select one or more test suites containing test cases.",
"loc.input.label.testConfiguration": "Test configuration",
"loc.input.help.testConfiguration": "Select Test Configuration.",
"loc.input.label.testLanguageInput": "Select Test framework language",
"loc.input.help.testLanguageInput": "Test Framework Language of automated tests in test plan",
"loc.messages.testPlanInput": "Test plan Id : %s",
"loc.messages.testplanConfigInput": "Test plan configuration Id : %s",
"loc.messages.testSuiteSelected": "Test suite Id selected: %s",
"loc.messages.automatedTestsTriggered": "Trigerring execution of Automated tests from test plan",
"loc.messages.ErrorFailTaskOnExecutingTests": "Error occured while executing test command",
"loc.messages.ErrorFailTaskOnAPIFailure": "Error occured while fetching automated tests from test plan inputs"
}
Loading