Allure Framework图表不显示求助:分类趋势、概述趋势缺失
Let's break down why you're only seeing the default Severity and Duration charts, plus missing Categories Trend and an empty Overview Trend section. Here are the most likely fixes to try:
1. Fix Version Compatibility Issues
Allure 2.5.0 is a fairly old release, and it might not play nicely with the version of allure-behave you're using. Mismatched versions often lead to incomplete widget data.
- First, upgrade the
allure-behaveplugin to a compatible version:pip install --upgrade allure-behave - Then, consider upgrading your Allure command-line tool to a newer stable release (e.g., 2.20.0) — older versions have known bugs around trend and category chart generation.
2. Ensure Historical Test Data is Preserved
The Overview Trend section relies on previous test run data to render trends. If you're starting fresh every time, there's no data to display. Here's how to retain history:
- Before running a new test suite, copy the existing
historyfolder from your oldallure-resultsto the new results directory:# Replace "old-allure-results" with your previous results path if [ -d old-allure-results/history ]; then cp -r old-allure-results/history allure-results/; fi - Run your behave tests with the Allure formatter:
behave -f allure_behave.formatter:AllureFormatter -o allure-results - Generate the report with the updated history:
Now the Trend section should populate once you have at least two test runs saved.allure generate allure-results -o allure-report
3. Add a Custom Categories Configuration
The Categories Trend chart won't appear unless you define custom failure categories in a categories.json file. Allure doesn't create this by default.
- Create
categories.jsonin yourallure-resultsdirectory with a structure like this (adjust to your needs):[ { "name": "Critical Failures", "matchedStatuses": ["FAILED"], "messageRegex": ".*critical.*" }, { "name": "Flaky Tests", "matchedStatuses": ["BROKEN", "PASSED"] }, { "name": "Minor Issues", "matchedStatuses": ["SKIPPED"] } ] - Re-run your tests and regenerate the report — the Categories Trend chart should now show up with your defined categories.
4. Verify Widget JSON Integrity
Even if the JSON files exist in allure-reports/widgets, they might be empty or incomplete:
- Open
trend.json— it should contain an array of objects with data from multiple test runs. If it only has one entry, the Trend section will stay blank. - Check
categories.jsonin the widgets folder — if it's empty, that means Allure didn't detect any matching categories (double-check yourcategories.jsoninallure-results).
5. Clean and Re-Generate the Report
Old report cache can sometimes cause display issues. Start fresh with these steps:
# Delete existing results and report rm -rf allure-results allure-report # Re-run tests to generate fresh results behave -f allure_behave.formatter:AllureFormatter -o allure-results # Generate report with clean flag to remove cache allure generate allure-results -o allure-report --clean
Most of the time, the missing charts boil down to missing history data, missing category config, or version mismatches. Work through these steps and you should see the charts populate correctly.
内容的提问来源于stack exchange,提问作者Jake

