Postman MCQ Questions and Answers for API Testing and Automation
Postman is one of the most popular tools for API testing and automation, enabling developers to write test scripts, automate suites, and integrate with CI/CD pipelines. This article provides 30 Postman MCQ questions and answers covering essential topics like test scripts, assertion libraries, Newman, CI/CD integration, and performance testing to boost your API testing skills.
1. Writing Test Scripts with JavaScript
Which language is used for writing test scripts in Postman? a) Python b) JavaScript c) Ruby d) PHP
What is the purpose of the pm object in Postman test scripts? a) To interact with the API server b) To provide methods for writing and executing tests c) To manage environment variables d) To log test results
Which method is used to assert response status in a Postman test script? a) pm.assert b) pm.response.to.have.status c) pm.test d) pm.verify.status
What is the purpose of the pm.environment object in Postman? a) To create APIs b) To set and retrieve environment variables c) To debug scripts d) To store test results
Which command outputs test results to the console in Postman? a) console.output b) pm.debug c) console.log d) pm.console.log
2. Assertion Libraries in Postman
Which assertion library is used in Postman by default? a) Mocha b) Chai c) Jest d) Jasmine
How do you check if a response body contains a specific string in Postman? a) pm.response.to.include b) pm.expect(response.body).to.include c) pm.response.has.string d) pm.expect(body).to.have.string
What is the use of pm.expect in Postman? a) To define new APIs b) To verify API response values c) To create collections d) To export test results
How can you verify if an API response time is within 200ms in Postman? a) pm.test("Response time is below 200ms", function () { pm.response.time < 200; }); b) pm.expect(pm.response.time).to.be.below(200); c) pm.response.test.time(200); d) pm.test.responseTime(200);
What assertion verifies if the response has a JSON object in Postman? a) pm.expect.to.have.json b) pm.response.to.be.json c) pm.response.json() d) pm.expect(pm.response.json()).to.be.an('object');
3. Automating Test Suites with Newman
What is Newman in the context of Postman? a) A CI/CD tool b) A Postman plugin c) A command-line runner for Postman collections d) A debugging tool
Which command is used to execute a Postman collection using Newman? a) newman execute <collection> b) postman run <collection> c) newman run <collection> d) npm postman <collection>
How do you specify an environment file when running Newman? a) --environment <file> b) -env <file> c) --env-file <file> d) -e <file>
Which file format is supported for exporting Postman collections? a) JSON b) XML c) YAML d) CSV
How can you view a summary of test results after running Newman? a) By exporting results as JSON b) By reviewing console output c) By enabling Newman’s dashboard d) By opening a log file
4. Integration with CI/CD Pipelines
Which CI/CD tool is commonly used to integrate Postman tests with pipelines? a) Jenkins b) Travis CI c) GitHub Actions d) All of the above
How can you integrate Newman with a Jenkins pipeline? a) By adding Newman commands to the Jenkinsfile b) By installing a Postman plugin c) By exporting collections as XML d) By using Newman only locally
What is the purpose of integrating Postman tests with CI/CD pipelines? a) To replace manual testing completely b) To automate test execution during development cycles c) To generate API documentation d) To debug code in the pipeline
Which GitHub Action is used for running Postman collections? a) actions-runner b) postman/newman-action c) run-newman d) github-postman
What is the benefit of using Newman in CI/CD pipelines? a) Reduces execution time b) Provides real-time debugging c) Automates collection runs and generates detailed reports d) Validates code syntax
5. Performance and Load Testing
Can Postman be used for performance testing? a) Yes, using iterations and data files b) No, Postman is only for functional testing c) Yes, but only in Pro versions d) No, Postman does not support load testing
Which feature in Postman helps simulate concurrent requests? a) Workspaces b) Runner with data files c) Mock Server d) Debugger
How can you measure the response time of an API in Postman? a) By checking the Test tab b) By using the pm.response.time property c) By viewing the console logs d) By exporting the results
Which tool can be used alongside Postman for advanced load testing? a) Apache JMeter b) Newman c) Mocha d) Selenium
What is the purpose of adding delays between requests in Postman? a) To simulate real-world scenarios b) To debug API responses c) To save resources d) To test authentication
General Automation and Debugging
Which Postman feature allows scheduled execution of tests? a) Mock Server b) Postman Monitor c) Newman Runner d) Console
How can Postman help debug API requests? a) By providing a debugger tool b) By enabling request logging in the console c) By exporting logs to files d) By using the Runner
What is the purpose of the Pre-request Script tab in Postman? a) To validate request headers b) To execute scripts before the main request c) To set response expectations d) To automate documentation
Can Postman export test results for analysis? a) Yes, as JSON and HTML reports b) No, Postman does not support exporting results c) Only for premium users d) Only for CI/CD pipelines
How do you troubleshoot failed requests in Postman? a) By analyzing response codes and logs b) By running the collection in debug mode c) By using the Newman dashboard d) By re-running the failed request
Answer Table
Qno
Answer (Option with the text)
1
b) JavaScript
2
b) To provide methods for writing and executing tests