Skip to content

Latest commit

 

History

History
80 lines (51 loc) · 4.65 KB

part1-PrepareForLaunch.md

File metadata and controls

80 lines (51 loc) · 4.65 KB

Prepare for Launch

In this section we're going to create a workspace, import a collection, authorize our requests, and add a test.

1. Create a workspace

In the Postman app, create a personal or team workspace to organize your workshop output.

  • Open the dropdown at the top of the app and select Create New > enter a name and Create Workspace.

2. Import a collection

Postman collections let you organize groups of requests together with associated elements such as tests and documentation. You can create your own and import others.

We'll import a few collections as we work through the topics. Having these in your Postman app will give you loads more requests to play around with after the session.

  • Click New+, tab over to API Network, and search for "Learning". Select Sue's API Learning Resources listing.
  • Import the VIP Customers collection using the Run in Postman button.
  • Open the VIP Customers collection and click the second request Get customer to open it. Take a minute to look at the parts of the request with data entered (highlighted in green). Check out the collection variables to see where the URL components are coming from (open the collection menu and select Edit > Variables).
  • Send the request and look at the response data. The API sends back JSON—see the status code, and hover over the response time and size breakdowns. You can also save the response as an Example you can use in documentation and mock servers.
  • Open the PATCH Add customer request and check out the data it's sending in the Params, Authorization, and Body. Remember the collection variables included the token value. Send the request.

3. Test a request

Let's add some test JavaScript code to the request.

  • In the Tests tab, insert a test snippet from the right sidebar at the top of the script. Remember that the status code was 200 OK. Choose Status code: Code is 200 from the list.
  • Notice that the test includes a message you'll see alongside it in test result output, and uses Chai.js syntax to create the assertion.
  • Save the request and Send it again, and check out the Test Results.
  • Open the Get customers request (first in the folder) and in the Tests tab, add the same status code 200 test, but this time edit the test to fail, e.g. by testing for a 400 response code instead of 200. Save and Send the request again, and observe the test results, noticing the difference in the failed message.

4. Run a collection

You can run all of the requests in a collection or folder using the collection runner.

  • Click Runner and select the VIP Customers collection.
  • Click Run VIP Customers to see the requests run. By default they'll run in the order they're listed in the collection folder, but you can change that as we'll see soon.

Your request tests need to be saved to appear in the collection runner so remember to hit Save in the requests._

  • Import another collection to see more tests run. Click New > Templates and search for "echo". Import the Postman Echo collection.
  • Open the collection runner again, choose the Postman Echo collection, and run it.
  • Check out the Run Summary and notice you can filter on passed or failed tests. You can also access past test runs when you open the runner or by navigating back after a run.

winter solstice art

Recap

In this section we tried out:

  • creating a workspace
  • importing a collection
  • using variables
  • authorizing requests
  • test scripts
  • running collections

Kahoot

Go to kahoot.it and enter the pin shown on the screen—answer the questions as quick as you can to win an Amazon gift card!

Additional resources

Check out the Postman docs for more on these topics:

See also:

Next steps

Next up: Final Countdown