9

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);
});
});
Suhail Ahmed
  • 504
  • 1
  • 9
  • 19
  • tried generating report via maven but it gave me an error saying Build failed, pom.xml file not found, from where can i get pom.xml for this project since I have only 2 files.? – Suhail Ahmed Jun 10 '18 at 11:13

4 Answers4

16

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

jithinkmatthew
  • 890
  • 8
  • 17
1

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

Suhail Ahmed
  • 504
  • 1
  • 9
  • 19
1

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

allure generate 'available report folder path' && allure open
0

Taken from the jasmine allure reporter github

In this method, we will use Maven. Copy ready-to-use pom.xml from node_modules/jasmine-allure-reporter and run:

mvn site -Dallure.results_pattern=allure-results

It will put HTMLs into target/site/allure-maven-plugin folder. To serve them via localhost:1324 use:

mvn jetty:run -Djetty.port=1234

You can also use this one from one of my projects- link, however check if the dependencies are correct - these are around 6+ months old.

demouser123
  • 4,108
  • 9
  • 50
  • 82