Skip to main content
Specialist
Sep 20, 2023 8:39 AM UTC
Question

[Testim] How to Get a result of an iteration?

Hi All,

 

I am using TESTIM for running automated test cases. I am using TESTIM_ITERATOR for running the same steps with different parameters. At the end of the entire test suite, I am getting result of each Iterator, which I have to manually go and have to check. Screenshot - 

List of Iterations

Is there any way, where I can get the result of the current Iterator in the JS?

6 replies

Employee
Sep 20, 2023 3:19 PM UTC

Hi Pramod,

Try using an after-test Hook to write the paramaeter’s value to a CSV file for example.
Also, you can request the team to create a Feature Request for a different solution.

Feel free to reach out to our support team for further assistance.

Specialist
Sep 21, 2023 1:05 PM UTC

Hello Meital,

 

Thanks for the reply. The after-test Hook doesn’t seem to fulfil my entire requirement. I want a csv or excel result to be generated.

Could you explain me how could I do that? Is there any demo example available for the same?

Specialist
Sep 23, 2023 11:37 AM UTC

Hi,

I have made little progress on this. Instead of writing the data into a CSV file, I am now writing it directly to MongoDB using the Node test server.

But now the problem is, as I am using parameters with multiple iterations (TESTIM_ITERATOR), I would like to execute the hook at the end of each iteration, and if that iteration fails, then the hook is supposed to get executed.

Could you tell me how I can achieve this?

Employee
Sep 25, 2023 9:21 PM UTC

Hi, 


I would like to execute the hook at the end of each iteration, and if that iteration fails, then the hook is supposed to get executed.

 

After test hook should be used when we need to run an action (shared group/step) after the test run ended: https://help.testim.io/docs/hooks

In this case as it seems like you are trying to run a certain action after each group iteration (and not just once after the test run), I suggest either splitting the test run so each test run will represent a single iteration, and run the test data driven, so you will have the test running every time with the next data set automatically. With this approach the after test hook logic can apply, as each run is a single iteration.

OR

Incase we need the group loops iterations in the same run and cannot be split for diff runs each with its own data set, Then we can simply add the needed action (that we want to perform after each iteration, regardless is passed/failed), as the last step of the group loop.

Then, group all prior loop steps AND mark the condition of when this step fails to “Mark error & continue”.
 


This should make sure we always reach the last step to run the action, regardless of success or failure of an iteration. But still will fail the test accordingly once the full run ends.

It should look something like so:
 

This is essentially mimicking the after test hook logic on a small iteration scale.

Let me know if it helped, or if any further assistance is needed :) 
 

Specialist
Sep 26, 2023 8:35 AM UTC

Hi Matan,

Thanks for the quick response and a workaround. I am using group iteration and such multiple groups are being used one after another. It is not possible to make the single iteration as one test.

In the workaround that you have mentioned, it is going to execute the hook every time, even if the iteration is failed or passed. I just want my hook to be executed when the test case is failed. 

If that’s not possible,  then can I at least get the Iteration status as Pass/Fail in the Javascript? In that case, I could write a condition based on Iteration status.

Thanks in advanced! 

Kat
Employee
Sep 28, 2023 1:27 PM UTC

 If you are a paying customer and you’d like to reach the Support team directly you can email them support@testim.io or chat with them from inside your active testim.io project

Quality Matters, Kat