How to parametrize the runner's testcase name by csv?


The red lines~

Hey @tester20183450,

It’s unclear what you’re asking for here - Would you be able to add more context to the question, please?

Hi Danny,

I think his question is, how to parametrize the test case name, where it can be uniquely identified.

As per his above report he got multiple iterations with different sets of data, so I believe the test name will be same for all individual iterations, so he want some unique test name for each iteration.

Thanks,
Mahi

1 Like

I don’t think that you can currently change that part of the request to make it more dynamic.

As a workaround and really basic way of getting something unique to that dataset, you could add this in that Test name,:

pm.test(`${pm.info.requestName} - Id: ${pm.iterationData.get('id')}`, function () {
      // Check for something here...
});

That would give you the request name and also reference a pre-defined id on the column or property of the data file.

One of the clear downsides of this is that if you run the single request in the app, you’re going to have a test name like GET Request - Id: undefined returned :frowning:

It’s not perfect but that could be used to do a quick visual check in the Collection runner?

1 Like

I have a similar question and your solution really helps me, thank you Danny.

1 Like

I think I have this similar issue.
I’m trying to use some CSV columns to store the expect results for each cenario (csv row).
It work pretty well to get the data on the body requests, but I’m still working my ass of to make work on the tests scripts.
I did not found anything on the docs so far

Thanks in advance

Hey @giuberti,

Welcome to the community!! :star:

Could you please show an example of what you’re doing and what’s not working for you.

Might be better with images to explain what’s going on and allow folks to help you out :grin:

1 Like

Hey @dannydaiton,

I´m using a simplified project to make these tests.
I´m basically trying to use the csv columns (in my example, [cenario] and [acaoEsteira]) to validate my tests.

image

All columns work pretty fine on the request body.

But, i´m trying to use both also on the Tests scripts, like above:

image

And it do not work. As the way above I get only as string.

image

If I try to get them as pm.global (or pm.enviroment) I get a previoslly stored value, or undefined.

I´ve also tried to use some pm.interationData, as showed here, but it do not work.

I´m using the lastest version (7.5.0)

Thanks in advance

The curly braces syntax is not for the test scripts, the variables won’t be automatically resolved.

You need to use the variables API to access the variables in the scripts.

You can write one of the following:

let cenario = pm.iterationData.get('cenario');

or

let cenraio  = data['cenario'];

Also, for globals and environments, you can use their API’s i.e pm.environment.get('key') and pm.globals.get('key').

Docs:

1 Like

Hello @sivcan,
now it work pretty well. I used iterationData correctally this time.

Thank you guy so much!
Greetings

1 Like