魅力-报告中缺少执行的测试用例

时间:2020-03-09 10:09:49

标签: python pytest allure

测试框架-pytest(版本4.6.9)[allure-pytest(版本-2.8.10)]

Python版本-2.7.8

以下命令用于运行测试。

pytest --alluredir=test-results/allure-results test_cases.py

以下是pytest.ini的内容。

[pytest]
addopts = -ra --tb=auto --disable-warnings --show-capture=no
log_format = %(asctime)s %(levelname)s %(message)s
log_date_format = %Y-%m-%d %H:%M:%S
log-auto-indent = True
log_cli = True
log_cli_format = %(asctime)s [%(module)s] [%(levelname)s] %(message)s
log_cli_date_format = %Y-%m-%d %H:%M:%S

以下命令用于创建诱惑报告。

allure generate --clean --report-dir test-results/report test-results/allure-results

生成命令完成,但出现以下错误并生成报告

Could not read test result file test-results/allure-results/833bb231-5fb5-4090-ac73-4b10ad0ea4f1-result.json (PID 15489)
com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input (PID 15489)
at [Source: (sun.nio.ch.ChannelInputStream); line: 1, column: 0] (PID 15489)
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)(PID 15489)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4145) (PID 15489)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4000) (PID 15489)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3070) (PID 15489)
at io.qameta.allure.allure2.Allure2Plugin.readTestResult(Allure2Plugin.java:344) (PID 15489)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) (PID 15489)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source) (PID 15489)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source) (PID 15489)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) (PID 15489)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source) (PID 15489)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source) (PID 15489)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source) (PID 15489)
at java.util.stream.ReferencePipeline.forEach(Unknown Source) (PID 15489)
at io.qameta.allure.allure2.Allure2Plugin.readResults(Allure2Plugin.java:104) (PID 15489)
at io.qameta.allure.ReportGenerator.lambda$readResults$0(ReportGenerator.java:47) (PID 15489)
at java.util.ArrayList.forEach(Unknown Source) (PID 15489)
at io.qameta.allure.ReportGenerator.readResults(ReportGenerator.java:47) (PID 15489)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) (PID 15489)
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) (PID 15489)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source) (PID 15489)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source) (PID 15489)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) (PID 15489)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) (PID 15489)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source) (PID 15489)
at java.util.stream.ReferencePipeline.collect(Unknown Source) (PID 15489)
at io.qameta.allure.ReportGenerator.generate(ReportGenerator.java:69) (PID 15489)
at io.qameta.allure.ReportGenerator.generate(ReportGenerator.java:58) (PID 15489)
at io.qameta.allure.Commands.generate(Commands.java:104) (PID 15489)
at io.qameta.allure.CommandLine.run(CommandLine.java:152) (PID 15489)
at java.util.Optional.orElseGet(Unknown Source) (PID 15489)
at io.qameta.allure.CommandLine.main(CommandLine.java:88) (PID 15489)
Report successfully generated to test-results/report (PID 15489)

该报告所包含的测试用例要比执行的测试用例少一个。在上面的输出中,我们可以看到一个result.json文件是问题的原因。

Could not read test result file test-results/allure-results/833bb231-5fb5-4090-ac73-4b10ad0ea4f1-result.json

在allure-results文件夹中选中时,以上文件为空。

ls -lrth 833bb231-5fb5-4090-ac73-4b10ad0ea4f1-result.json
-rwxrwx--- 1 root vboxsf 0 Mar  3 15:10 833bb231-5fb5-4090-ac73-4b10ad0ea4f1-result.json

pytest成功生成了测试用例的相应日志。

ls -lrth a8b9e869-cd5f-422d-b3f2-2f4b696119b3-attachment.txt
-rwxrwx--- 1 root vboxsf 1.9K Mar  3 15:10 a8b9e869-cd5f-422d-b3f2-2f4b696119b3-attachment.txt

我怀疑allure-pytest存在一些问题,我相信它将生成相应的result.json文件。

我想用allure-python报告此问题。在此之前,我想知道我是否可以做些什么。

0 个答案:

没有答案