Allure Newman

Allure Newman npm latest version

Generate beautiful HTML reports using Allure Report and your Newman tests.

Allure Report Newman Example

How to start

1. Prepare your project

  1. Open a terminal and go to the project directory. For example:

    cd /home/user/myproject
  2. Install the Allure Report command-line tool, if it is not yet installed in your operating system. Note that Allure Report requires Java, see Installation.

    npm install --save-dev allure-commandline
    yarn add --dev allure-commandline
    pnpm install --dev allure-commandline
  3. Install the Allure Newman adapter.

    npm install --save-dev newman-reporter-allure
    yarn add --dev newman-reporter-allure
    pnpm install --dev newman-reporter-allure

2. Run tests

When running Newman:

  1. Specify either a URL or a file path of your Postman collection.

  2. Specify a list of Newman reporters that includes the allure reporter. You may want to include cli (the Newman's default reporter) as well to keep the terminal output informative.

  3. Specify additional Allure Newman configuration options if necessary.

For example:

npx newman run \ --reporters cli,allure \ --reporter-allure-export output/allure-results
yarn dlx newman run \ --reporters cli,allure \ --reporter-allure-export output/allure-results
pnpx newman run \ --reporters cli,allure \ --reporter-allure-export output/allure-results

This will save necessary data into allure-results. If the directory already exists, the new files will be added to the existing ones, so that a future report will be based on them all.

3. Generate a report

Finally, run Allure to convert the test results into an HTML report. This will automatically open your browser to view the report.

npx allure serve allure-results
yarn dlx allure serve allure-results
pnpx allure serve allure-results

If necessary, replace allure-results with the path to the directory specified in the Configuration.

There are some options that can affect how the report is generated, see Allure command-line options.

Writing tests

The Allure Newman adapter extends the standard reporting features of Newman by providing additional capabilities for crafting more informative and structured tests. This section highlights key enhancements that can be utilized:

Adding Metadata

Allure allows you to enrich your reports with a variety of metadata. This additional information provides context and details for each test, enhancing the report's usefulness. Refer to the metadata reference section for an exhaustive list of what can be added.

To assign a metadata field, call a corresponding method at any point inside a test method's body. Note, however, that it is highly recommended to assign all metadata as early as possible. Otherwise, there is a risk of the test failing before having all metadata set, which is bad for the test report's readability.

// @allure.label.owner=JohnDoe // @allure.label.severity=critical // @allure.label.tag=WebInterface // @allure.label.tag=Authentication pm.test("Test Authentication", function () { // ... });

Adding links to issues and other webpages is currently not supported by the Allure Newman adapter.

Organize tests

As described in Improving navigation in your test report, Allure supports multiple ways to organize tests into hierarchical structures.

To specify a test's location in the behavior-based hierarchy:

// @allure.label.epic=WebInterface // @allure.label.feature=EssentialFeatures // @allure.label.story=Authentication pm.test("Test Authentication", function () { // ... });

To specify a test's location in the suite-based hierarchy:

// @allure.label.parentSuite=WebInterface // @allure.label.suite=EssentialFeatures // @allure.label.subSuite=Authentication pm.test("Test Authentication", function () { // ... });

Divide a test into steps

If a Postman request has multiple pm.test() calls in its “Tests” section, Allure will display them as separate test steps.

pm.test("Make sure the response is valid JSON", function () { // ... }); pm.test("Compare the response with the expected data", function () { // ... });

Select tests via a test plan file

Test plan is currently not supported by the Allure Newman adapter.

Environment information

For the main page of the report, you can collect various information about the environment in which the tests were executed.

For example, it is a good idea to use this to remember the OS version and Node.js version. This may help the future reader investigate bugs that are reproducible only in some environments.

Allure Report Environments Widget

To provide environment information, put a file named into the allure-results directory after running the tests. See the example in Environment file.

Note that this feature should be used for properties that do not change for all tests in the report. If you have properties that can be different for different tests, consider using Parametrized tests.

Powered by

Join our newsletter

Join our community

We aim to make Allure Report as reliable and user-friendly as possible, and together with the community, we're here to help when problems arise.

© 2024 Qameta Software Inc. All rights reserved.