# Tests for branch

**URL:** <https://community.postman.com/t/tests-for-branch/8436>\
**Category:** Help Hub\
**Tags:** newman-project, tests, automation, collections\
**Created:** [October 17, 2019, 8:24pm UTC](https://community.postman.com/t/tests-for-branch/8436 "2019-10-17T20:24:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshua](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@joshua](https://community.postman.com/u/joshua)\
**Post date:** [October 17, 2019, 8:24pm UTC](https://community.postman.com/t/tests-for-branch/8436/1 "2019-10-17T20:24:49Z")

</div>

How are people testing their applications in development?

I have a repo, “store” (example). I have Postman which I can setup to commit the collection to a Git repo.

I use a normal Git Flow. I want to commit to a feature branch. I want to create tests in that branch before I merge the develop/master. I want to run those tests on that branch, but they’ll fail on develop/master until the code is merged.

Is Postman setup to do that? It doesn’t seem like it can do that now. If not, how are other people doing this with a team?

---

<div class="post-metadata">

**Author:** ![singhsivcan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/singhsivcan/32/1595_2.png) [@singhsivcan](https://community.postman.com/u/singhsivcan)\
**Post date:** [October 18, 2019, 6:38am UTC](https://community.postman.com/t/tests-for-branch/8436/2 "2019-10-18T06:38:32Z")

</div>

@joshua You can integrate [newman](https://www.npmjs.com/package/newman) in your CI/CD pipeline and then every-time that you’ll push your code, the tests will run.

You can [search the community](https://community.postman.com/search?q=CI%2FCD), there are multiple topics out there related to the same.

[Postman docs also show how you can integrate with jenkins](https://learning.getpostman.com/docs/postman/collection_runs/integration_with_jenkins/)

---

<div class="post-metadata">

**Author:** ![joshua](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@joshua](https://community.postman.com/u/joshua)\
**Post date:** [October 18, 2019, 4:43pm UTC](https://community.postman.com/t/tests-for-branch/8436/3 "2019-10-18T16:43:26Z")

</div>

@singhsivcan I looked and didn’t see a solution before I posted.

The problem is that Postman/Newman isn’t actually integrated with the development pipeline. It’s external to it. I want to know what/when broke my code. I figure if people are using Postman/Newman in a CI/CD pipeline, they aren’t exporting their collection and environment on every commit. That seems like a huge burden and very prone to breaking. Even then, how do you isolate your changes from everyone else’s if you’re working in a team?

I’m excited to bring my API Request GUI inline with my CI/CD pipeline, but I’m having a hard time figuring out how Newman is going to help me more than OAS and Dredd.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 18, 2019, 5:02pm UTC](https://community.postman.com/t/tests-for-branch/8436/4 "2019-10-18T17:02:30Z")

</div>

This post by @matt might be helpful and give you some pointers:

> **[Elevate your automation game by using Git Hooks](https://medium.com/better-practices/git-hooks-for-automation-135c62bca7d7)**
>
> Automatically consume APIs and perform behind-the-scenes actions with your everyday Git commands

---

<div class="post-metadata">

**Author:** ![murdoc-she-wrote](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/murdoc-she-wrote/32/2289_2.png) [@murdoc-she-wrote](https://community.postman.com/u/murdoc-she-wrote)\
**Post date:** [October 22, 2019, 7:57pm UTC](https://community.postman.com/t/tests-for-branch/8436/5 "2019-10-22T19:57:23Z")

</div>

> I figure if people are using Postman/Newman in a CI/CD pipeline, they aren’t exporting their collection and environment on every commit.

They shouldn’t have to unless they are updating the integration tests.

You should have a standard collection (think BVT) that is designed to be run on every pull request in your CI/CD pipeline.

---

<div class="post-metadata">

**Author:** ![joshua](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@joshua](https://community.postman.com/u/joshua)\
**Post date:** [October 22, 2019, 9:39pm UTC](https://community.postman.com/t/tests-for-branch/8436/6 "2019-10-22T21:39:54Z")

</div>

The integration tests get updated constantly as things change.

What is BVT? The collection I have contains all of our API endpoints. The plan is to run the tests on every PR, but we can’t do that if we are going to have tests breaking in master because we’re adding the code in an upcoming branch.

---

<div class="post-metadata">

**Author:** ![murdoc-she-wrote](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/murdoc-she-wrote/32/2289_2.png) [@murdoc-she-wrote](https://community.postman.com/u/murdoc-she-wrote)\
**Post date:** [October 23, 2019, 5:24pm UTC](https://community.postman.com/t/tests-for-branch/8436/7 "2019-10-23T17:24:01Z")

</div>

> The integration tests get updated constantly as things change.

Nice. So you have multiple developers working off the same collections or do you use something else for your integration tests?

> What is BVT?

Build Verification Test. These tests should give you an idea if your build is testable (not necessarily shippable).

> The collection I have contains all of our API endpoints.

Great so you run tests on _all_ your endpoints? What about critical workflows?

> The plan is to run the tests on every PR, but we can’t do that if we are going to have tests breaking in master because we’re adding the code in an upcoming branch.

The integration tests should be added with the new feature.  
Would you mind elaborating on your SDLC? It’s odd to hear about tests breaking in master (instead of develop).

---

<div class="post-metadata">

**Author:** ![joshua](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@joshua](https://community.postman.com/u/joshua)\
**Post date:** [October 23, 2019, 5:31pm UTC](https://community.postman.com/t/tests-for-branch/8436/8 "2019-10-23T17:31:41Z")

</div>

Right now we’re using OAS 2.0 with Dredd. I’m evaluating a move to Postman.

All our endpoints have tests. At least, that they return a 200 status. Not very much is tested past that.

The SDLC isn’t unusual. How I’m describing it is, heh. What I mean is that Postman is missing a critical feature that the requests for Newman aren’t tied to the code. Say I have a collection and it is running all of the tests OK while running tests on develop and master. Then, I create a feature branch. I want to test the new feature so I add a request to the collection. That test fails for anyone that doesn’t have their environment set to my feature branch.

If I don’t have that test, how do we know if my feature works? How do we know _when_ it broke? It doesn’t pass our “definition of done” if it doesn’t have tests so I can’t even merge it. It’s a catch 22 if the tests aren’t along side the code.

---

<div class="post-metadata">

**Author:** ![james.pohl](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@james.pohl](https://community.postman.com/u/james.pohl)\
**Post date:** [October 23, 2019, 5:46pm UTC](https://community.postman.com/t/tests-for-branch/8436/9 "2019-10-23T17:46:34Z")

</div>

Joshua, I believe you are asking if you have a API breaking change on a branch in your GitHub and have the corresponding updates to the integration tests on a forked version of that API’s collection, can you configure your CI pipeline to use Newman and run the matching branches?

**If so, in my experience, Postman does not support this.** The Postman API does not expose the Postman branch name when [querying collections](https://docs.api.getpostman.com/?version=latest#647806d5-492a-eded-1df6-6529b5dc685c). So even if you know the Postman branch you want to use with Newman, you won’t be able to programmatically get the collection uid. You can do some hacky things, like include a branch name in the collection description or include a collection uid in your repo. But even doing this, it would be hard to trigger a merge of the forked Postman collection in sequence with the merge of your GitHub branch.

My approach so far has been to avoid breaking API and test changes as much as possible. This allows for the master Postman collection to be updated and for CI to still function. When changes can’t be avoided, manually executing tests on a Postman branch and including evidence in the PR for reviewers (then merge the two branches manually at the same time). In the most extreme cases, we would need to block the CICD queue for that API to perform testings/merges.

My current approach is not sustainable or scalable. Hopefully, someone else has a real solution or Postman will provide better support for this. Anytime your tests and code are in different repos CICD gets much more complicated.

---

<div class="post-metadata">

**Author:** ![murdoc-she-wrote](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/murdoc-she-wrote/32/2289_2.png) [@murdoc-she-wrote](https://community.postman.com/u/murdoc-she-wrote)\
**Post date:** [October 24, 2019, 3:33pm UTC](https://community.postman.com/t/tests-for-branch/8436/10 "2019-10-24T15:33:50Z")

</div>

Hey Joshua,

I think James covered it well, if your tests and features are being merged asynchronously, that can be a bit problematic. In my team we try develop the tests and feature in parallel or as soon as possible, at least this has been our interpretation of the [Shift Left approach](https://en.wikipedia.org/wiki/Shift-left_testing).

One other thing jumped out at me in your response:

> At least, that they return a 200 status. Not very much is tested past that.

That’s a good start, but I assume your consumers of your APIs are looking for more than just status codes. Our team gets a lot of value out of asserting expected responses here. I’d start with something simple and validate one workflow that can _never_ break.
