In this final part of the chapter, we will be importing some tests and getting them to run in Postman.
As I mentioned in the course introduction, we'll be using Amber Race's code from her Exploring Service APIs Through Test Automation course that is available on Test Automation University.
The code associated with that course is also available on GitHub.
We're going to get that code into Postman in the easiest way possible, which is to use the "Import from code repository" feature within Postman.
You'll need to have a GitHub account to do this.
If you don't, they're free to set up, or I show you another way of doing this in an extra video that I've put a link to in the Resources section.
The first thing you can do is go to GitHub and find the code we're looking for.
I have forked the salient parts of Amber's code, so we have everything we need.
If you go and Google "Beth Marshall GitHub", you'll see my GitHub repo named "askherconsulting" here, if you click on it, you'll see pinned to the front of the GitHub repo is "explore-with-postman". Click there.
If you've got a GitHub repo, go ahead and click the "Fork" button here.
What that will do is copy all of this detail into your own GitHub account, so you could then download it from Postman.
So how do we do that?
Assuming you forked the code, what I'd then like you to do is go back into Postman and click on the "Import" button.
We can see here there's lots of different ways of importing the code.
The extra video that I've given to you shows you how to do that via raw text.
It's a good thing to learn, but we're going to go ahead and click "Code repository" because a really handy feature is to be able to import directly from GitHub.
Go ahead and click Code Repository.
It wants to authenticate your GitHub profile, so click "Continue".
Then you can go ahead and go back into Postman.
Once we open Postman back up, we can select our GitHub organization.
This will be the name of your own repo, and for repository, we're going to select "explore-with-postman".
Now we've got our account and we've got our repo.
Press "Continue", and we can see that it has recognized the different types of code for our Restful Booker platform.
We've got our collection here, so we definitely want to import our collection.
If you prefer to download code locally and have a local instance, you can do that - Amber's course will show you how, but for ease of use, we're going to go ahead and just select "Production".
So, we'd like to import the production environment and the Restful Booker BVT collection.
Hit "Import", and that's all done for us.
We can see here, we have one collection and we have one environment.
So, our code has been imported.
If we select the "Collections" option here on the side menu, we can see our Restful Booker code has been imported.
Open that, and you can see all of the endpoints, which were mapped by Amber, and you can drill down even further and see the endpoints in detail.
Each of these has a different test - tests in Postman can live in this "Tests" tab here.
We have lots of tests here in all of this code. How do we go ahead and run those in an automated way?
To do that, we use the Postman collection runner.
So what I'd like you to do is highlight the collection, select the three dot menu and go to "Run collection".
This will open a new tab for the collection runner.
Now these are all of our endpoints and we can select the environment that we want to run the tests against; we're going to go ahead and select "Production".
That's the environment that we imported earlier.
All we need to do now is click "Run" and you can see just up here that "Passed" and "Failed" count will start to go up.
There are expected failures within this repo - that's perfectly fine.
So we now have a suite of test cases that are running through our collection runner.