// Store all test names
const testNames = Object.keys(pm.testResult.getTestNames());
// Log test names to console
console.log("List of pm.test names:");
testNames.forEach(name => console.log(name));
Additionally also with current execution status for mp.test
If you just want the test case names, you could potentially call the Postman Collection API which returns all of the details related to a collection as a JSON response.
You could then search for the particular request and get access to the code in the tests tab. Have a look at the submit requests on the 15 day of Postman for Testers or 30 Days of Postman for Developer challenges to see examples on how to query the collection JSON. (I’ll show an example at the bottom of this post).
What is your use case for this. (Over just reading the test results tab)?
Example of working with the Collection API. (Although this seems like overkill).