Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate allure report

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);
});
});
like image 938
Suhail Ahmed Avatar asked Jun 10 '18 11:06

Suhail Ahmed


People also ask

What is an allure report?

Allure Report is a flexible, lightweight multi-language test reporting tool. It provides clear graphical reports and allows everyone involved in the development process to extract the maximum of information from the everyday testing process.


3 Answers

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.

Note : If the report is in loading state, please try to open in different browsers

like image 158
jithinkmatthew Avatar answered Oct 11 '22 00:10

jithinkmatthew


If the allure report is available then the report can be viewed with the below command

allure generate 'available report folder path' && allure open
like image 37
Jayabharathi Palanisamy Avatar answered Oct 10 '22 23:10

Jayabharathi Palanisamy


I got the solution, an easy 1,

Allure setup in your system

  1. Download allure latest version [downloadAllur][1]
  2. extract the binary file
  3. in System PATH variable add allure->bin path,
  4. check whether allure is installed or not, in cmd prompt run allure

Step to generated allure report

  1. run you test cases, allure-report folder with json files and screenshots is created
  2. open cmd prompt
  3. run following cmd in cmd prompt allure serve path_of_allure-report_folder_generated

The above command is used to only view the report

If we have generated the "allure-report" folder using the command

allure generate path_of_allure-report_folder_generated --clean -o allure-report

then there are chances that the index.html might not display any report due to browser constraints, so to open this index.html it is always good practice to open it from the command prompt using below command

allure open path_of_'allure-report'_folder_generated

like image 31
Suhail Ahmed Avatar answered Oct 11 '22 00:10

Suhail Ahmed