# How do I print a variable value along with the string in the Test results

**URL:** <https://community.postman.com/t/how-do-i-print-a-variable-value-along-with-the-string-in-the-test-results/22971>\
**Category:** Help Hub\
**Tags:** tests, variables, test-results\
**Created:** [April 22, 2021, 10:08am UTC](https://community.postman.com/t/how-do-i-print-a-variable-value-along-with-the-string-in-the-test-results/22971 "2021-04-22T10:08:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jagrutiwani0](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jagrutiwani0](https://community.postman.com/u/jagrutiwani0)\
**Post date:** [April 22, 2021, 10:08am UTC](https://community.postman.com/t/how-do-i-print-a-variable-value-along-with-the-string-in-the-test-results/22971/1 "2021-04-22T10:08:33Z")

</div>

I want to print the variable value along with the string in the Test Results. How should I do that?  
I tried different ways but I want to append that variable along with the string in pm.test

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/2/3/2341beaacbc792df08a04d4846b16e5704ba3b7f.png)

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [April 22, 2021, 10:33am UTC](https://community.postman.com/t/how-do-i-print-a-variable-value-along-with-the-string-in-the-test-results/22971/2 "2021-04-22T10:33:19Z")

</div>

Hi @jagrutiwani0 ,

You are trying to print the variable value in the test name is it?

It’s the same way, you can access using pm.environment.get(“LeadID”)

```auto
pm.test("Response body contains the ID as " + pm.environment.get("LeadID"), function () {
          var jsonData = pm.response.json();
        pm.expect(jsonData.Id).to.eql(pm.environment.get("LeadID"));
    });

```

“+” is used to append the values in the Test name.

Please try this and let me know if you are facing any issue 😊

---

<div class="post-metadata">

**Author:** ![jagrutiwani0](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jagrutiwani0](https://community.postman.com/u/jagrutiwani0)\
**Post date:** [April 22, 2021, 10:40am UTC](https://community.postman.com/t/how-do-i-print-a-variable-value-along-with-the-string-in-the-test-results/22971/3 "2021-04-22T10:40:13Z")

</div>

Hi @bpricilla ,

Thank you so much 🙂 It worked.

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [April 22, 2021, 10:49am UTC](https://community.postman.com/t/how-do-i-print-a-variable-value-along-with-the-string-in-the-test-results/22971/4 "2021-04-22T10:49:20Z")

</div>

Similar topic is discussed [here](https://community.postman.com/t/include-variable-in-pm-test/21937/2). You can use replaceIn as well like,

```auto
pm.test(pm.variables.replaceIn("Response body contains the ID as {{LeadID}}"), function () {
          var jsonData = pm.response.json();
        pm.expect(jsonData.Id).to.eql(pm.environment.get("LeadID"));
    });

```

---

<div class="post-metadata">

**Author:** ![jagrutiwani0](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jagrutiwani0](https://community.postman.com/u/jagrutiwani0)\
**Post date:** [April 22, 2021, 10:53am UTC](https://community.postman.com/t/how-do-i-print-a-variable-value-along-with-the-string-in-the-test-results/22971/6 "2021-04-22T10:53:10Z")

</div>

Okay, thanks!! I Will try with the **replaceIn** method also.
