TestProject Forum

How do I extract a list of Tests or Jobs of a Project? [SOLVED]

Hello everyone,

Is it possible or is there an option in TestProject to extract all the tests and jobs in a list with the dependencies for a specific project?

Thanks a lot for your help.


Hello @k.gillet
Like we talked about in the chat.
This endpoint will return all tests of a project: https://api.testproject.io/docs/v2/#/Tests/Tests_GetTestsForProject
And this endpoint will return all Project jobs: https://api.testproject.io/docs/v2/#/Jobs/Jobs_GetJobsForProject

So together they get what you need.

And for the 2nd requirement, this endpoint returns all the tests in a Job: https://api.testproject.io/docs/v2/#/Jobs/Jobs_GetJobTests

I created a simple Powershell script which exports a list of tests in a project to a .csv file if anyone wants to use it. You will need to set the apitoken and projectid below.

To use it, you need:

  1. API token - see Getting Started With Using the TestProject API - TestProject Documentation.
  2. Project ID - you can click on the three dots next to the project name to access that option.

Here is the script, copy and save it to a .ps1 file. Remember to edit the values on the top and anything else to your liking.

# Copy your TestProject tokens here
$apitoken = 'Unset'
$projectid = 'Unset'

# File name for your csv file
$outfile = "TestProject_Tests"+ (Get-Date -Format "yyyyMMdd") + ".csv"

# Add or remove desired fields here
$fields = @("id", "name", "description", "creationDate", "modificationDate", "type", "platform")

# Request parameters
$Body = @{
    'detailed' = 'true'
    '_start' = 0
    '_limit' = 0

# Request details
$params = @{
    Uri         = "https://api.testproject.io/v2/projects/$projectid/tests"
    Headers     = @{ 'Authorization' = "$apitoken" }
    Method      = 'GET'
    Body        = $Body
    ContentType = 'application/json'

# Get all the tests and export to csv
$response = Invoke-RestMethod @params
($response | Select-Object $fields) | Export-Csv $outfile -NoTypeInformation

After executing it, it should save a file in the same directory and you should get something like this: