Test metrics at job level per API

In the Insights tab I am able to see the number of tests that ran as part of a job in a workflow. However, in the Insights API I have only been able to find an aggregated value for all tests across the workflow. What I need is the number of tests per job, not just the aggregated number for the entire workflow. Is this available through the API? I looked but couldn’t find it.

Hello @BorislavaNikolova,

Assuming you’re storing the test results, you could leverage the “Get test metadata” API v2 endpoint combined with some jq to get a high-level view of your test results.

Something like this:

curl -G https://circleci.com/api/v2/project/<project-slug>/<job-number>/tests \
-H "Circle-Token: <your_personal_API_token>" | jq '.items | { "Total number of tests":.|length, "Tests successful":map(select (.result == "success")) | length, "Tests skipped":map(select (.result == "skipped")) | length,"Tests failed":map(select (.result == "failure")) | length }'

Let me know if this helps.