How to generate allure report

Suhail Ahmed picture Suhail Ahmed · Jun 10, 2018 · Viewed 33.5k times · Source

I am new to allure reports and want to generate the allure report. Can anyone help with this?

I am trying with a simple example, my project folder containing config.js and test.js and the allure report installed

when I run the config file it is creating a folder allure-results, in that I can see the screenshots and a xml file. I have no idea what to do from here, I am trying with maven but not able to generate the html report.

I have added the code of my example

config.js

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: 'test.js',

onPrepare: function () {
    var AllureReporter = require('jasmine-allure-reporter');
    jasmine.getEnv().addReporter(new AllureReporter({
        allureReport: {
            resultsDir: 'allure-results'
        }
    }));
    jasmine.getEnv().afterEach(function (done) {
        browser.takeScreenshot().then(function (png) {
            allure.createAttachment('Screenshot', function () {
                return new Buffer(png, 'base64');
            }, 'image/png')();
            done();
        });
    });
}
};

test.js

describe('angularjs homepage todo list', function () {
var todoList = element.all(by.repeater('todo in todoList.todos'));

it('should add a todo', function () {
    browser.get('https://angularjs.org');

    element(by.model('todoList.todoText')).sendKeys('write first protractor test');
    element(by.css('[value="add"]')).click();
});

it('test 2', function () {
    expect(todoList.count()).toEqual(3);
});

it('test 3', function () {
    expect(todoList.get(2).getText()).toEqual('write first protractor test');
});

it('test 4', function () {
    // You wrote your first test, cross it off the list
    todoList.get(2).element(by.css('input')).click();
    var completedAmount = element.all(by.css('.done-true'));
    expect(completedAmount.count()).toEqual(2);
});
});

Answer

jithinkmatthew picture jithinkmatthew · Jun 15, 2018

Direct Answer : By using Allure Command Line Tool you can generate report.

when I run the config file it is creating a folder allure-results, in that I can see the screenshots and a xml file.

As you said, it is generating test result data and screenshot in that folder. You can generate report after this. Follow below steps.

  1. Add this dependency by running npm install allure-commandline --save-dev
  2. Run your tests and generate test result data (ie, after running it will generate allure-results folder).
  3. From the same project directory run, allure generate allure-results --clean -o allure-report in the command prompt
  4. On successfull execution it will generate one more folder allure-reportin your directory.
  5. Open index.html file in FireFox to show the report.