How to Allure-behave generate report from test cases. Allure generated only one report from one test case

Łukasz Krause picture Łukasz Krause · Mar 13, 2018 · Viewed 9.2k times · Source

When I use this step from here twice:

$ behave -f allure_behave.formatter:AllureFormatter -o %allure_result_folder% ./features

And then

$ allure serve %allure_result_folder%

There is always 1 test case. How can I manage to sum test cases? I want to see test cases.

I've run also this code twice:

behave -f allure_behave.formatter:AllureFormatter -o results ./features

and then:

allure generate results/ -o report/

But still, I get only 1 test case.

I want to see for example similar outcome

Answer

Cynic picture Cynic · Mar 19, 2018

I have a couple guesses at what's going on wrong.

First you said you've run the same thing twice which makes me think you may have an incorrect assumption on how Allure seems to organize results. If you've only written 1 Behave scenario, running the same test twice will only show 1 test. If you click on the test subsequent runs show up under the "Retries" tab (Not sure why it isn't called history but if you need History it's now at bottom of answer). You'll need 2 behave scenarios for a second test to appear.

enter image description here

Second, you're results folder seems to be changing paths you mention both report, results and %allure_result_folder%. Make sure you create a results folder before running behave and have the same path for -o in the behave command and after allure serve. So for example if you have a folder structure like so:

folder_you_are_in/ ├── features/ │ ├── steps/ ├── allure/ │ ├── results/ | ├── reports/

You want to run the command like so:

behave -f allure_behave.formatter:AllureFormatter -o allure/results ./features

Then the path you need to allure generate & allure open (not allure serve, not sure why but serve doesn't seem to take history into account when it generates as part of command) and make sure your paths match your file structure:

allure generate allure/results/ -o allure/reports
allure open allure/reports

The screenshot seems to show just a test with multiple Feature files and scenarios. But if you're looking for how to make History Work you need to move the history file from previous report into the results file for new report for some reason this is only done automatically with the build plugins and must be run manually when testing locally. So something like this:

First test run

 behave -f allure_behave.formatter:AllureFormatter -o allure/results ./features

Generate report for first test run

 allure generate allure/results/ -o allure/reports

Second Test Run

 behave -f allure_behave.formatter:AllureFormatter -o allure/results ./features

Copy the History Folder from the Report Generated at Step 2 to The Results from Step 3

 cp -R allure/reports/history allure/results/history

Generate the 2nd Allure Report

 allure generate allure/results/ -o allure/reports --clean

And open it with

 allure open allure/reports