Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krishnapollu/azure-devops-testplan-java-sdk
SDK to integrate your automated test results to Azure DevOps Test Plan
https://github.com/krishnapollu/azure-devops-testplan-java-sdk
azure-devops azure-testplan sdk test-automation
Last synced: 6 days ago
JSON representation
SDK to integrate your automated test results to Azure DevOps Test Plan
- Host: GitHub
- URL: https://github.com/krishnapollu/azure-devops-testplan-java-sdk
- Owner: krishnapollu
- Created: 2023-08-05T18:45:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-21T21:57:36.000Z (11 months ago)
- Last Synced: 2024-11-05T19:23:38.990Z (about 2 months ago)
- Topics: azure-devops, azure-testplan, sdk, test-automation
- Language: Java
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# azure-testplan-sdk
Java based SDK to integrate your automation test results to Azure DevOps Test Plan. Add this library to your pom.xml and use the methods to POST your test results to Azure DevOps. This SDK internally uses the Azure DevOps REST APIs to update the results to your project.
### Maven Dependency
```mavencom.testautomation
azure-devops-testplan-java-sdk
1.0-SNAPSHOT```
### Usage
The below snippets are to be added in your hooks or listeners so that this gets executed after each test case execution.Set basic details of your Azure DevOps server / project. To be set during the beginning of the execution.
```java
//init config class
AzureConfig.organization = "";
AzureConfig.project = "";
AzureConfig.accessToken = "";
AzureConfig.setBaseURL();
```The Azure DevOps Test Execution has the below hierarchy
`` Test Plan --> Test Suite --> Test Run --> Test Results --> Test Points ``Setting the Test Suite Entity
```java
TestSuiteEntity testSuiteEntity = new TestSuiteEntity();
testSuiteEntity.setPlan_id(606035); // update with your Test Plan ID
testSuiteEntity.setParentSuiteId(606036); // update with your Test Suite ID
testSuiteEntity.setQueryString("Automation_TC", AzureConfig.project);
testSuiteEntity = TestSuite.create(testSuiteEntity);
```Creating a Test Run
```java
//create testrun
TestRunEntity testRunEntity = new TestRunEntity();
testRunEntity.setTestPlanId(606035); // update with your Test Plan ID
testRunEntity.setName("Test Suite");
testRunEntity = TestRun.create(testRunEntity);
```Create a Test Result Entity against each Test Case you execute
```java
//test case - 745460
TestCaseEntity testCaseEntity1 = new TestCaseEntity();
testCaseEntity1.setId(745460); // update with test case ID
testCaseEntity1 = TestCase.get(testCaseEntity1, testSuiteEntity);
TestPointEntity testPointEntity1 = TestPoint.get(testCaseEntity1, testSuiteEntity);TestResultEntity testResultEntity1 = new TestResultEntity();
testResultEntity1.setOutcome("Passed"); // RUn status
testResultEntity1.setTestCaseId(testCaseEntity1.getId());
testResultEntity1.setTestPointId(testPointEntity1.getId());
testResultEntity1.setTestCaseTitle(testCaseEntity1.getName());
testResultEntity1.setDurationInMs(12000); // test case execution duration//test case - 745466
TestCaseEntity testCaseEntity2 = new TestCaseEntity();
testCaseEntity2.setId(745466);
testCaseEntity2 = TestCase.get(testCaseEntity2, testSuiteEntity);
TestPointEntity testPointEntity2 = TestPoint.get(testCaseEntity2, testSuiteEntity);TestResultEntity testResultEntity2 = new TestResultEntity();
testResultEntity2.setOutcome("Failed");
testResultEntity2.setErrorMessage("java.lang.NullPointerException");
testResultEntity2.setStacktrace(ExceptionUtils.getStackTrace(new Exception()));
testResultEntity2.setTestCaseId(testCaseEntity2.getId());
testResultEntity2.setTestPointId(testPointEntity2.getId());
testResultEntity2.setTestCaseTitle(testCaseEntity2.getName());
testResultEntity2.setDurationInMs(1000);
```Now add the Test Result Entities to Test Run
```java
TestResult.add(testResultEntity1, testRunEntity);
TestResult.add(testResultEntity2, testRunEntity);
```Update the Test Run
```java
testRunEntity = TestRun.update(testRunEntity, "Completed",
"Automated Test Run completed successfully.");
```#### Git Repo: [azure-devops-testplan-java-sdk](https://github.com/krishnapollu/azure-devops-testplan-java-sdk)