You can run your Postman tests automatically with Newman.
Optic helps you run your existing Postman tests against your project, adding in schema checks for every request and response seen. The tests you have today can help establish the baseline behavior of your API and assert that your API is behaving according to the specification Optic has recorded. Tests are run with a single command:
api run test
Before running tests, you'll need to integrate with your current project. We recommend following the instructions to set up your framework's
api start command, and to use a middleware integration where available:
If your project is integrated with Optic using middleware, configuring a test task is as easy as configuring a start task. If using a middleware integration is not feasible, Optic can use your working
start task to make running your tests through your proxy integration easy.
The middleware integration will assure Optic sees your traffic, no matter if it is sent interactively or through a test collection like with Postman. Since Postman tests are run manually, you will use your current
start task to start your application and activate the middleware. No configuration changes are needed either in Optic or in Newman.
Postman will use the same definition that was already set up to intercept traffic with
api start. You'll need to confirm Postman is ready to send requests to the inboundUrl defined in the
start task. Open Postman and check the URL and port of your requests. We suggest parameterizing your URL in some fashion, and using Postman Environments to set the values of these parameters. For example, below we have an environment
Optic on 3001 that defines a baseUrl value of
http://localhost:3001. This matches the inboundUrl of our start task in
name: "todo-js"tasks: start: command: node server.js --watch db.json --routes routes.json --port $PORT inboundUrl: http://localhost:3001
As this is a manual integration, you'll use
api start to start up your API and run your Postman tests by hand. When testing, substitute the
api start or
api run start commands for
api test or
api run test. Postman testing with Optic can be automated using Newman.