npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@thecollege/azure-test-track

v1.0.13

Published

Azure DevOps utilities for test plan and test run management

Downloads

139

Readme

Tests and Publish npm version Downloads

The @thecollege/azure-test-track package simplifies the integration with Azure DevOps for managing and updating test runs. It provides methods to create test runs, add test results, and retrieve test data, facilitating streamlined test tracking.

Main Workflow of the Script

The script automates the process of associating test results with Azure DevOps Test Plans and Test Runs. Here's the step-by-step workflow:

  1. Read Test Results:

    • The script first reads the test result file, typically in JUnit XML format (until at the moment). It extracts each test case's ID (in the format TC_ID), along with the status (whether it passed, failed).
  2. Create a Test Plan:

    • Before running the automation, you need to create a Test Plan in Azure DevOps. This Test Plan will contain the tests you want to associate with the automation results.
  3. Search for Test Plan by ID:

    • The script then searches for the Test Plan by its name (set in the environment variables or the testSettings object).
  4. Retrieve Test Points:

    • After identifying the Test Plan, it retrieves the associated Test Points based on your test result. Test Points are individual test executions corresponding to each test case within the Test Plan. These points represent the actual execution of the test cases.
  5. Associate Build ID:

    • The script attempts to associate the Build ID (i.e., the identifier of the pipeline that executed the tests) if the BUILD_BUILDID environment variable is available. This helps track which pipeline executed the tests.
  6. Create Test Run:

    • A Test Run is created in Azure DevOps, associating the tests from your results to the Test Plan and Test Points. This step ensures that the executed tests are logged under the correct Test Plan in Azure DevOps.
  7. Update Test Run Results:

    • The script updates the Test Run with the results of each individual test case, marking whether each test passed or failed based on the test results.
  8. Mark Test Run as Completed:

    • Finally, the script marks the Test Run as completed in Azure DevOps, signaling that the automation process is finished.

This automation significantly streamlines the process of tracking test results and associating them with the relevant Test Plan and Test Runs in Azure DevOps.

Supported Test Result Format

At the moment, this package supports only JUnit XML format for test results. The expected format is as follows:

<testsuite name="login.spec.ts" timestamp="2024-11-07T21:18:21.215Z" hostname="chromium" tests="1" failures="0" skipped="0" time="367.297" errors="0">
  <testcase name="TC_1234567 - User should be able to do login with success" classname="login.spec.ts" time="211.158">
  </testcase>
</testsuite>
  • Test Case ID Format: The test case ID from Azure DevOps must follow the format TC_[ID_FROM_AZURE] in your test result file. This ID will be used to link the results to the corresponding test case in Azure DevOps.

For any other result file format, please, contact me or contri

Installation

To install the package, run:

npm install @thecollege/azure-test-track

Requirements

Environment Variables

Before using this package, ensure you have the following environment variables set in your environment:

ADO_ORGANIZATION: Your Azure DevOps organization name.

ADO_PROJECT: Your Azure DevOps project name.

ADO_PERSONAL_ACCESS_TOKEN: Your Azure DevOps personal access token with the necessary permissions.

Usage

One of the main methods of this package is createTestRunByExecution, which allows you to create a test run and update results based on a provided test plan name and test result file.

Example

Here's an example of how to use createTestRunByExecution:

const { createTestRunByExecution } = require('@thecollege/azure-test-track');

const planName = process.env.TEST_PLAN_NAME || "YOUR PLAN NAME";
const testSettings = {
    resultFilePath: './test-results/results.xml',
    planName: planName,
    testRunName: "[Regression][Platform] E2E Automated Test Run"
};

const reportTestResults = async () => {
    await createTestRunByExecution(testSettings);
};

reportTestResults();

Method Details

createTestRunByExecution: Reads test results from a JUnit XML file and creates a new test run in Azure DevOps for a specified test plan. If the build ID is available as an environment variable (BUILD_BUILDID), it links the test run to that build ID. Other Available Methods This package also provides additional methods to support a variety of tasks in Azure DevOps test management. For example, you can retrieve all test points for a specific test plan using the getAllTestPointsByPlanName method.

Example

const { getAllTestPointsByPlanName } = require('@thecollege/azure-test-track');

const testPlanName = "Your Test Plan Name";
const getTestPoints = async () => {
    const testPoints = await getAllTestPointsByPlanName(testPlanName);
    console.log("Test Points:", testPoints);
};

getTestPoints();

Note

You can explore and utilize other methods provided in this package for various test management tasks, such as creating test runs without tests, resetting test points to active status, and retrieving test runs by build ID. Refer to the source code or documentation for detailed information on each method.

Contributing and Other Result Formats

Currently, the package supports only JUnit XML format for test results. However, we are open to adding support for other formats in the future.

If you need support for a different test result format, or if you would like to contribute to this package, please feel free to reach out. You can open an issue or create a pull request to propose changes or additional formats.

How to Contribute

  1. Fork the repository.
  2. Create a new branch for your feature or fix.
  3. Make your changes.
  4. Submit a pull request with a clear description of your changes.

We welcome any contributions to improve the package!