getting 404 error when generating allure report in

2020-04-27 07:33发布

问题:

I am trying to generate allure report in protractor for the first time,

To generate allure report I am using jasmine allure reporter:1.0.2 and allure-commandline tool:2.7.0 versions

In my conf file I have added the code for generating xml results in a specific folder and then I am using allure-commandline tool to generate html report which gets generated in a folder named "Allure-report" in the project home directory, but now when I open the index.html file generated by using allure-commandline tool then I see 404 error in the different sections of report

Further I also tried to run following commands :-

mvn site -Dallure.results_pattern= F:\Backup\Protractor-Workspace\Typescript_framework\Test_results\Allure-result ,this command to generate html report from xml files which get generated upon running spec files.

and also tried to start jetty server using command :-

mvn jetty:run -Djetty.port=1332 this command starts jetty server

but in both cases, I got error:-

The goal you specified requires a project to execute but there is no POM in this directory

Further, To explain further, I also tried to start jetty server from inside node_modules/jasmine-allure-reporter folder but found that there is no pom.xml file in it due to which I again got "no POM in this directory" error

Please let me know what I should do now?

Below is the code I wrote in conf.ts file for generation of allure report :-

var AllureReporter = require('./node_modules/jasmine-allure-reporter');
    jasmine.getEnv().addReporter(new AllureReporter({
      resultsDir: './Test_results/Allure-result'
        })
      );
  var allure = require('allure-commandline');
  var generation = allure(['generate', './Test_results/Allure-result']);
   generation.on('exit', function(exitCode:any) {
      console.log('Generation is finished with code:', exitCode);
    });
   },

Below are the screenshot of my project folder structure and the html report with 404 not found error

report screenshot

Project folder structure

回答1:

You should not open index.html file like a normal html.

allure will spin up a web server.

"scripts": {
"allure": "node_modules/.bin/allure generate ./allure-results -c && allure open"
},

add this to your script in package.json.

After your allure-results folder is created (i.e) test completes run npm run allure

After you run npm run allure. Your default browser will automatically open the report.