Allure报告HTML未加载JSON数据。

huangapple go评论70阅读模式
英文:

Allure report html is not loading json data

问题

我使用Java运行测试并使用Allure收集结果。结果文件夹allure-results生成了一堆JSON文件。如果我使用allure serve allure-results,我可以看到报告。

但是,我想生成HTML,以便以后随时查看。所以我通过allure generate allure-results --clean -o allure-report来实现。结果会生成一个包含HTML文件的文件夹。然而,当我打开这个文件时,数据没有加载。请参见下面的附件。

在控制台中,我收到了CORS策略错误。示例如下:

从来源 'null' 阻止了对 'file:///Users/jgitlin/Documents/proj/CommServ_E2E_Automation/build/allure-results/widgets/summary.json' 的 XMLHttpRequest 访问,因为已阻止跨源请求,仅支持以下协议方案:http、data、isolated-app、chrome-extension、chrome、https、chrome-untrusted。

是我生成报告的方式存在问题,还是有方法可以正确查看HTML?

英文:

I run tests using Java and collect the results with Allure. As a result folder allure-results generated with banch of json files. I can see the report if I use
allure serve allure-results.
However, I want to generate html that I can view any time later. So I do it by allure generate allure-results --clean -o allure-report. As a result folder with html file is generated. However, when I open this file the data is not loaded. Please see the attachment below.Allure报告HTML未加载JSON数据。
In console I get CORS policy errors. The example is below.

Acess to XMLHttpRequest at 'file:///Users/jgitlin/Documents/proj/CommServ_E2E_Automation/build/allure-results/widgets/summary.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.

Is there a problem in the way I generate the report or is there a way to see the html properly?

答案1

得分: 1

你可以轻松地使用你选择的任何Web服务器来提供Allure报告,例如Python内置的HTTP服务器可以,让我为你解释一下吧。

首先,在终端或命令提示符中导航到生成"Allure报告"的目录。

然后,像这样启动Python HTTP服务器(它将在端口9001上启动服务器,但你可以使用任何其他端口号):

python -m http.server 9001

最后,打开你的浏览器并访问http://localhost:9001/allure-report以查看Allure报告!

使用这种方法,你可以绕过CORS策略,使浏览器正确加载所需资源。

祝你好运!

英文:

You can easily use any web server of your choice to serve the Allure report, for example Python's built-in HTTP is ok let me explain it to you

first of all open a terminal or command prompt and navigate to the directory where the Allure report is generated

then, start Python HTTP server like this (it will start the server on port 9001, but you can use any other port number you like!):

python -m http.server 9001

at the end, open your browser and go to http://localhost:9001/allure-report to view the Allure report!

with this method,you are bypassing the CORS policy and allowing the browser to load the necessary resources properly

good luck !

答案2

得分: 0

你可以使用Allure命令行来查看实际报告;

> allure open allure-report

英文:

You can use allure commandline to see actual report;

> allure open allure-report

huangapple
  • 本文由 发表于 2023年6月9日 11:14:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76436981.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定