# Adding PASSED/FAILED to a variable from Test Result

**URL:** <https://community.postman.com/t/adding-passed-failed-to-a-variable-from-test-result/77741>\
**Category:** Help Hub\
**Tags:** tests, variables, test-results\
**Created:** [March 27, 2025, 1:28pm UTC](https://community.postman.com/t/adding-passed-failed-to-a-variable-from-test-result/77741 "2025-03-27T13:28:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![splechko](https://avatars.discourse-cdn.com/v4/letter/s/8e8cbc/32.png) [@splechko](https://community.postman.com/u/splechko)\
**Post date:** [March 27, 2025, 1:28pm UTC](https://community.postman.com/t/adding-passed-failed-to-a-variable-from-test-result/77741/1 "2025-03-27T13:28:51Z")

</div>

Hi all!

I can get two status in the Test Result tab - PASSED or FAILED.  
I want to extract this information (PASSED or FAILED) and get it to the variable. I need only word - Passed or Failed. I attached screenshots what I want to get.

 ![1](https://us1.discourse-cdn.com/getpostman/original/3X/9/0/9076b619ce393298043d2d7d2c8683e7532d143e.jpeg)  
 ![2](https://us1.discourse-cdn.com/getpostman/original/3X/6/c/6c77778996fcdb2d994e47d290a1084eff046d11.jpeg)

How can I extract this information? Please help!

BR,  
Sergey

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [March 27, 2025, 2:27pm UTC](https://community.postman.com/t/adding-passed-failed-to-a-variable-from-test-result/77741/2 "2025-03-27T14:27:36Z")

</div>

You can’t access the test results programmatically.

Please see the following topic for more information.

[https://community.postman.com/t/get-testresults-value-passed-failed-saved-in-a-variable](https://community.postman.com/t/get-testresults-value-passed-failed-saved-in-a-variable)

What you can do though is edit the test cast and create the variable and result here instead.

For example.

```auto
pm.test("Status code is 200", () => {
    // set inital status to fail
    pm.collectionVariables.set("testStatus", "FAILED")
    // your assertion
    pm.response.to.have.status(200);
    // If the assertion fails, then the current pm.test execution will end immediately.
    // No further code in this test block will execute.
    // The testStatus will remain as failed.
    // If the next line executes, it means that the assertion passed.
    pm.collectionVariables.set("testStatus", "PASSED")
});

```

![image](https://us1.discourse-cdn.com/getpostman/original/3X/5/a/5acc8df323a5251e0950b21269036200c5b8ff27.png)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/6/f/6fdd938b54d6ab7b2a58157bc12c8741e3255838.png)

If I force the assertion to fail by changing the status code to 201.

![image](https://us1.discourse-cdn.com/getpostman/original/3X/b/5/b55dcd420e766d3ea4b8228092eba73ef8266d2d.png)

The status of the variable is now failed.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/7/1/7110ddf6b46b9f5e470af8606cb16f33c33b542b.png)

---

<div class="post-metadata">

**Author:** ![splechko](https://avatars.discourse-cdn.com/v4/letter/s/8e8cbc/32.png) [@splechko](https://community.postman.com/u/splechko)\
**Post date:** [March 27, 2025, 3:10pm UTC](https://community.postman.com/t/adding-passed-failed-to-a-variable-from-test-result/77741/3 "2025-03-27T15:10:12Z")

</div>

Hi! Thank you for reply.
