Skip to content

The Azure DevOps Test Plan Exporter is a Python-based tool designed to extract and export test plan data from Azure DevOps into a structured CSV format. It retrieves comprehensive information about test plans, suites, cases, and their execution results, including detailed test steps and expected outcomes.

Notifications You must be signed in to change notification settings

chuls5/python-azureTestPlanExporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ§ͺ Azure DevOps Test Plan Exporter

πŸš€ Extract ALL the juicy details from your Azure DevOps test plans with hierarchical structure and execution history!

This comprehensive Python tool doesn't just export test cases - it captures the complete testing story! Get hierarchical test suite structures, detailed test steps, shared steps resolution, execution history, and so much more. Perfect for deep test analysis, reporting, and quality insights! πŸ“Šβœ¨

πŸš€ Quick Start

πŸ“‹ What You Need

  • 🐍 Python 3.6+ installed on your machine
  • 🏒 Azure DevOps organization with test plans
  • πŸ”‘ Personal Access Token (PAT) with Test Management and Work Items read permissions
  • πŸ’» Git (to download the tool)

If you already have Python installed, skip to Step:4

Otherwise, please follow along to install Python globally on your machine.


This section will guide users who do not have Python or VS Code installed.

πŸ› οΈ Installing Python and Visual Studio Code

πŸ“₯ Step 1: Install Python

  1. Download Python:

  2. Run the Installer:

    • Open the downloaded installer.
    • Important: Check the box that says "Add Python to PATH".
    • Click "Install Now" and follow the prompts.
  3. Verify Installation:

    • Open Command Prompt (Windows) or Terminal (Mac/Linux).
    • Type the following command and press Enter:
      python --version
    • You should see the installed Python version.

πŸ’» Step 2: Install Visual Studio Code

  1. Download VS Code:

  2. Run the Installer:

    • Open the downloaded installer.
    • Follow the installation prompts.
  3. Install Python Extension:

    • Open VS Code.
    • Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the left side of the window.
    • Search for "Python" and install the official Python extension by Microsoft.

πŸ” Step 3: Verify VS Code Setup

  1. Open a New Terminal in VS Code:

    • Go to the menu and select Terminal > New Terminal.
  2. Check Python Installation in VS Code terminal:

    • In the terminal, type:
      python --version
    • Ensure it shows the correct Python version.

If you are having trouble, make sure you installed the official Microsoft Python VScode extension in Step: 2.3


πŸ“₯ Step 4: Set Up Your Projects Folder

  1. Create a Folder on Your Desktop:

    • Right-click on your desktop and select New > Folder.
    • Name the folder "projects".
  2. Open Visual Studio Code:

    • Launch VS Code from your applications or start menu.
  3. Open the Projects Folder in VS Code:

    • In VS Code, go to the menu and select File > Open Folder....
    • Navigate to your desktop and select the "projects" folder you just created.
  4. Verify the Folder is Open:

    • Ensure that the "projects" folder is displayed in the Explorer pane on the left side of VS Code.

πŸ“₯ Step 5: Get the Tool

Option A: Download with Git (Recommended)

  1. Open a New Terminal in VS Code:
    • Go to the menu and select Terminal > New Terminal.
# Clone the repository to your computer
git clone https://github.com/chuls5/python-azureTestPlanExporter.git

# Go into the folder
cd python-azureTestPlanExporter

Option B: Manual Download

  1. 🌐 Go to the GitHub Repository Page:

  2. πŸ’š Click the Green "Code" Button:

    • On the repository page, locate the green button labeled "Code" and click on it.
  3. πŸ“¦ Download the ZIP File:

    • In the dropdown menu, click on "Download ZIP". This will download a compressed file containing the project files to your computer.
  4. πŸ“ Extract the ZIP File:

    • Navigate to your Downloads folder (or wherever the ZIP file was saved).
    • Right-click on the downloaded ZIP file and select "Extract All..." (or use your preferred extraction tool).
    • Choose a destination folder (you can extract it to the "projects" folder you created earlier) and click "Extract".
  5. πŸ’» Open Command Prompt/Terminal:

    • Open Command Prompt (Windows) or Terminal (Mac/Linux).
  6. Navigate to the Extracted Folder:

    • Use the cd command to change to the directory where you extracted the files. For example:
    cd path/to/your/extracted/folder
    • Make sure to replace path/to/your/extracted/folder with the actual path to the folder where you extracted the ZIP file.
  7. Verify the Files:

    • Once in the folder, you can list the files to ensure everything is extracted correctly by running:
    ls  # For Mac/Linux
    dir # For Windows

πŸ“¦ Step 6: Install Dependencies

Use the Python installer "pip", also known as, "python install package" to install the required packages for the project.

Since this Python script is interacting with Microsoft Azure API, install the following package:

# Install the required Python package
pip install requests

The requests package in Python is a popular and widely used library for making HTTP requests. It provides a simple and elegant API for interacting with web services, APIs, and web pages.

πŸ’‘ Beginner Tip: If you get a "pip not found" error, you might need to use python -m pip install requests instead.

πŸ”‘ Step 6: Get Your Personal Access Token (PAT)

Don't skip this step! You need this token to connect to Azure DevOps.

  1. 🌐 Go to your Azure DevOps in your web browser
  2. πŸ‘€ Click your profile picture in the top right corner
  3. βš™οΈ Click "Personal access tokens"
  4. πŸ†• Click "New Token"
  5. πŸ“ Fill out the form:
    • Name: Test Plan Exporter (or any name you like)
    • Expiration: Choose how long it should work (90 days is fine for testing)
    • Scopes: Click "Custom defined" and check these boxes:
      • βœ… Test Management β†’ Read
      • βœ… Work Items β†’ Read
  6. πŸ”΅ Click "Create"
  7. πŸ“‹ IMPORTANT: Copy the token that appears (you won't see it again!)

🎯 Step 7: Run the Tool

Basic command structure:

python azureTestPlanExporter.py --organization "your-org" --project "your-project" --pat "your-token" --test-plan-id "12345"

Real example (replace with your actual values):

python azureTestPlanExporter.py --organization "contoso" --project "MyAwesomeApp" --pat "abcd1234efgh5678ijkl" --test-plan-id "42"

πŸ” Where to find your information:

  • Organization: In your Azure DevOps URL β†’ https://dev.azure.com/ORGANIZATION-NAME
  • Project: The project name you see in Azure DevOps
  • Test Plan ID: Open your test plan in Azure DevOps, look at the URL β†’ .../_testManagement/execute?planId=TEST-PLAN-ID...

πŸŽ‰ Step 8: Check Your Results!

After running the command, you'll see:

  • βœ… Progress messages as it works
  • πŸ“Š A summary of what it exported
  • πŸ“ A new CSV file in the same folder (like test_plan_12345_export.csv)

Open the CSV file in Excel or Google Sheets to see your test data!

πŸ†˜ Complete Beginner Example

Let's say you have:

  • Organization: mycompany
  • Project: WebApp
  • Test Plan ID: 100
  • PAT: abc123def456ghi789

Step-by-step:

  1. Open Command Prompt (Windows) or Terminal (Mac/Linux)
  2. Navigate to your downloaded folder:
    cd Downloads/azure-devops-test-plan-exporter
  3. Run the command:
    python azureTestPlanExporter.py --organization "mycompany" --project "WebApp" --pat "abc123def456ghi789" --test-plan-id "100"
  4. Wait for it to finish (you'll see progress messages)
  5. Find your CSV file in the same folder!

πŸ”§ Troubleshooting for Beginners

❌ "python is not recognized" or "command not found"

  • Solution: Install Python from python.org and make sure to check "Add Python to PATH"

❌ "No module named 'requests'"

  • Solution: Run pip install requests (or python -m pip install requests)

❌ "Authentication failed"

  • Solution: Double-check your PAT token and make sure it has the right permissions

❌ "Test plan not found"

  • Solution: Verify the test plan ID is correct and you have access to it
Argument Required Description Example
🏒 --organization βœ… Azure DevOps organization name "contoso"
πŸ“ --project βœ… Azure DevOps project name "MyProject"
πŸ”‘ --pat βœ… Personal Access Token "your-secret-token"
πŸ§ͺ --test-plan-id βœ… Test Plan ID to export "12345"
πŸ“„ --output ❌ Custom filename for CSV output "my_export.csv"
πŸ› --debug ❌ Enable detailed debug logging (flag only)

πŸ” Finding Your Information

  • 🏒 Organization: Found in your Azure DevOps URL: https://dev.azure.com/{organization}
  • πŸ“ Project: The project name visible in your Azure DevOps interface
  • πŸ§ͺ Test Plan ID: Found in the test plan URL or the test plan details page

πŸ“ More Usage Examples

Save to a custom filename:

python azureTestPlanExporter.py --organization "your-org" --project "your-project" --pat "your-pat-token" --test-plan-id "12345" --output "my_test_results.csv"

Get detailed debug information:

python azureTestPlanExporter.py --organization "your-org" --project "your-project" --pat "your-pat-token" --test-plan-id "12345" --debug

✨ Features

  • πŸ—οΈ Complete Test Plan Export: Extracts test plans, suites, test cases, and individual test steps
  • πŸ“Š Hierarchical Structure: Maintains suite hierarchy with full path navigation (no more guessing where tests belong!)
  • 🎯 Execution History: Includes latest test results, outcomes, and execution dates
  • πŸ”— Shared Steps Resolution: Automatically flattens shared steps into individual test cases (magic! ✨)
  • πŸ“‹ Rich Metadata: Captures created dates, assigned testers, area paths, and automation status
  • πŸ› Debug Logging: Comprehensive logging with optional debug mode and file output
  • πŸ’Ύ CSV Export: Clean, structured CSV output for analysis and reporting
  • πŸ“ˆ Smart Analytics: Execution breakdowns, automation stats, and step counting

πŸ“Š Output Format Magic

The script generates a super-detailed hierarchical CSV file! Here's what you get:

πŸ“‹ Column Definitions

Column Description Example Values
🏷️ Type Row type identifier Suite, Test Case, Test Step, Separator
πŸ§ͺ Test Plan ID Source test plan identifier 12345
πŸ—‚οΈ Suite Path Full hierarchical path Smoke Tests > Login > Authentication
πŸ†” Suite ID Unique suite identifier 67890
🎯 Test Case ID Work item ID for test case 11111
πŸ“ Title Name/title of suite or test case Valid User Login Test
πŸ”’ Step Number Sequential test step number 1, 2, 3...
⚑ Step Action What to do in this step Navigate to login page
βœ… Expected Result What should happen Login page displays correctly
🎭 Execution Status Current execution state Completed, Not Executed
πŸ† Execution Outcome Test result Passed, Failed, Blocked
πŸ“… Last Run Date Most recent execution date 2024-03-15T14:30:22Z
πŸ‘€ Last Run By Who executed the test Jane Doe
πŸ‘₯ Assigned To Currently assigned tester John Smith
πŸ—“οΈ Created Date Test case creation date 2024-01-01T09:00:00Z
πŸ‘¨β€πŸ’» Created By Test case creator Test Manager
🏷️ Area Path Azure DevOps area path MyProject\\Features\\Auth
πŸ”„ Iteration Sprint/iteration path Sprint 1
πŸ€– Automated Automation status Yes, No

πŸ“ File Structure Example

The file structure is initially going to look like a lot.

Those of us who know Excel will have no problem "wrapping text" from the 'Step Action' and 'Expected Result' columns.

Type,Suite Path,Title,Step Number,Step Action,Expected Result,...
Suite,Smoke Tests > Login,SUITE: Login Tests,,,,,...
Test Case,Smoke Tests > Login,Valid User Login,,,,,...
Test Step,Smoke Tests > Login,,1,Navigate to login page,Login page displays,...
Test Step,Smoke Tests > Login,,2,Enter valid credentials,User is authenticated,...
Test Step,Smoke Tests > Login,,3,Click login button,User redirected to dashboard,...
Separator,,,,,,...

πŸ” Setting Up Your Personal Access Token (Detailed Guide)

πŸ€” What is a Personal Access Token?

Think of it as a special password that lets this tool talk to your Azure DevOps account safely. It's like giving the tool a visitor badge to your building.

πŸ“ Step-by-Step PAT Creation

  1. 🌐 Open Azure DevOps in your web browser
  2. πŸ‘€ Click your profile picture (top right corner)
  3. βš™οΈ Click "Personal access tokens"
  4. πŸ†• Click "New Token" (blue button)
  5. πŸ“ Fill out the form:
    • Name: Type something like Test Plan Exporter Tool
    • Organization: Select your organization (or leave as "All accessible organizations")
    • Expiration: Pick a date (30-90 days is good for testing)
    • Scopes: Click "Custom defined" and find these sections:
      • πŸ“Š Test Management - check the "Read" box
      • 🎯 Work Items - check the "Read" box
      • πŸ‘₯ Project and Team - check the "Read" box
  6. πŸ”΅ Click "Create"
  7. πŸ“‹ COPY THE TOKEN! It will show a long string of letters and numbers - copy this somewhere safe (like Notepad). You won't be able to see it again!

⚠️ Important Notes About Your Token

  • πŸ”’ Keep it secret - don't share it with others or post it online
  • ⏰ It expires - you'll need to create a new one when it expires
  • πŸ—‘οΈ You can delete it anytime by going back to Personal Access Tokens and clicking "Revoke"

πŸŽ‰ Example Output Summary

==================================================
🎯 EXPORT SUMMARY
==================================================
Total suites: 5 
Total test cases: 42 
Total test steps: 156 
Total rows exported: 208 

Execution Outcome breakdown:
  Failed: 3 (7.1%)
  Not Executed: 25 (59.5%)
  Passed: 14 (33.3%)

Execution Status breakdown:
  Completed: 17 (40.5%)
  Not Executed: 25 (59.5%)

Automation breakdown:
  Manual: 38 (90.5%)
  Automated: 4 (9.5%)

Average test steps per test case: 3.7

πŸ“Š Logging & Output

πŸ“’ Standard Output

  • πŸš€ Progress updates for major operations
  • πŸ“ˆ Summary statistics upon completion
  • ❌ Error messages for failed operations
  • πŸŽ‰ Celebration when everything works!

πŸ› Debug Mode Magic

When you use the --debug flag, you get:

  • πŸ” Detailed API request/response logging
  • πŸ‘£ Step-by-step processing information
  • πŸ“„ Debug log file: azure_exporter_debug_YYYYMMDD_HHMMSS.log
  • 🩺 Enhanced error diagnostics
  • πŸ•΅οΈ All the behind-the-scenes action!

🌟 Features in Detail

πŸ—οΈ Hierarchical Suite Organization

  • πŸ”— Builds complete suite hierarchy with parent-child relationships
  • πŸ“ Generates human-readable suite paths like "Regression > API > Authentication"
  • 🎯 Maintains original test plan structure in export
  • πŸ—ΊοΈ No more getting lost in complex test structures!

πŸ”— Shared Steps Resolution (The Cool Stuff!)

  • πŸ” Automatically detects shared step references in test cases
  • πŸ“₯ Fetches shared step details and expands them inline
  • 🎯 Supports nested shared steps (shared steps containing other shared steps!)
  • πŸ”’ Preserves step numbering after expansion
  • ✨ It's like magic, but with code!

πŸ“Š Execution History Integration

  • πŸ”— Correlates test cases with their latest execution results
  • πŸ” Searches across ALL test runs in the test plan
  • πŸ“… Provides execution outcome, date, and executor information
  • πŸ›‘οΈ Falls back to test point data when direct results aren't available
  • πŸ“ˆ Complete execution story, not just current status!

πŸ›‘οΈ Error Handling & Resilience

  • 🚨 Robust API error handling with detailed logging
  • πŸ”„ Graceful handling of missing or inaccessible test data
  • ⚑ Continues processing even if individual items fail
  • πŸ“‹ Comprehensive error reporting in debug mode
  • πŸ’ͺ Built to handle real-world messiness!

🚨 Troubleshooting

πŸ”§ Common Issues & Solutions

πŸ” Authentication Errors

  • βœ… Verify your PAT is valid and not expired
  • πŸ” Ensure PAT has required permissions
  • πŸ“ Double-check organization and project names are spelled correctly
  • πŸ”„ Try regenerating your PAT if issues persist, or granting "Full Access"

πŸ•΅οΈ Test Plan Not Found

  • πŸ†” Verify the test plan ID exists and is correct
  • πŸ” Ensure you have read permissions to the test plan
  • πŸ“ Check that the test plan is in the specified project
  • 🌐 Confirm you're connected to the right organization

πŸ“­ Empty Export Results

  • πŸ” Verify the test plan contains test suites and test cases
  • βœ… Check if test cases have been properly added to suites
  • πŸ› Enable debug mode to see detailed processing information
  • πŸ“Š Some test plans might have test cases but no execution history

⚑ Performance Issues

  • ⏰ Large test plans may take several minutes to process (be patient!)
  • πŸ› Enable debug mode to monitor progress
  • πŸ”„ Consider exporting smaller test plans if timeout occurs
  • πŸ“Š Check your internet connection stability

πŸ› Debug Information

Use the --debug flag to get insider information about:

  • 🌐 API requests and responses
  • πŸ” Test step parsing details
  • πŸ”— Shared steps resolution process
  • πŸ“Š Execution history correlation
  • πŸ’Ύ File I/O operations
  • πŸ•΅οΈ Everything happening under the hood!

⚠️ Limitations (The Fine Print)

  • 🌐 Requires internet connection to Azure DevOps (obviously!)
  • ⏰ Processing time increases with test plan size (bigger = slower)
  • πŸ“Š Some advanced test case fields may not be included
  • πŸ–ΌοΈ Attachments and images in test steps are not exported
  • πŸŽ›οΈ Test case parameters are not currently extracted
  • πŸ’‘ But hey, we're constantly improving!

🀝 Contributing

Want to make this tool even more awesome?

  1. 🍴 Fork the project
  2. 🌟 Create a feature branch (git checkout -b feature/amazing-feature)
  3. πŸ’» Make your changes
  4. πŸ§ͺ Test thoroughly (we love tests!)
  5. πŸ“¬ Submit a pull request
  6. πŸŽ‰ Celebrate your contribution!

πŸ’‘ Ideas for Contributions

  • πŸ“Š Additional export formats (JSON, Excel, etc.)
  • 🎨 Better CSV formatting options
  • πŸ” More detailed test step analysis
  • πŸš€ Performance optimizations
  • 🌐 Support for other Azure DevOps features

πŸ“ž Need Help?

Having trouble? We've got your back! πŸ’ͺ


🎊 Final Words

Happy Testing, Data Warriors! πŸ§ͺπŸ“Šβœ¨

Made with ❀️, β˜•, and countless hours of debugging for Azure DevOps users who believe that great testing deserves great tools!

Remember: Great test data leads to great products. You're not just exporting data - you're enabling better software! πŸš€


P.S. - If this tool saves you time, consider giving it a ⭐ star on GitHub! It makes our day! 😊

About

The Azure DevOps Test Plan Exporter is a Python-based tool designed to extract and export test plan data from Azure DevOps into a structured CSV format. It retrieves comprehensive information about test plans, suites, cases, and their execution results, including detailed test steps and expected outcomes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages