Create beautiful reports from your xUnit.net tests.
$ dotnet add package Allure.XunitAn Allure adapter for xUnit.net.
Allure Xunit supports the following frameworks:
Install the Allure.Xunit package and run the tests normally. In many cases,
allure should start automatically. The result files are created in the
allure-results directory in the target directory.
If that didn't happen, check out the Why the Allure results directory is empty?
section.
Learn more from the documentation for Allure Xunit.
Some examples are available here.
Previously, the package contained a mix of Allure.Xunit and Allure.XUnit
namespaces. Starting from 2.12.0, you should only use Allure.Xunit. The API is
still accessible through the old namespace, but that access is deprecated now
and will be removed in the future.
The following user API classes are now deprecated:
Allure.XUnit.Attachments - use Allure.Xunit.Attachments instead.Allure.XUnit.Attributes.Steps - use their counterparts from
Allure.Xunit.Attributes.Steps.The following previously deprecated user API classes and methods were removed:
Using-style steps/fixtures:
Allure.Xunit.AllureAfterAllure.Xunit.AllureBeforeAllure.Xunit.AllureStepAllure.Xunit.AllureStepBaseUse the following alternatives instead:
Allure.Xunit.Attributes.Steps ([AllureAfter],
[AllureBefore], or [AllureStep])Allure.Net.Commons.AllureApi and
Allure.Net.Commons.ExtendedApiAllure.Xunit.AllureAttachments - use
Allure.Net.Commons.AllureApi.AddAttachment instead.
Allure.Xunit.Steps - use functions from
Allure.Net.Commons.AllureApi and Allure.Net.Commons.ExtendedApi instead.
In Allure.Xunit.Attributes:
AllureXunitAttribute - use Xunit.FactAttribute instead.AllureXunitTheoryAttribute - use Xunit.TheoryAttribute instead.In Allure.Net.Commons.AllureLifecycle:
AddAttachment - use Allure.Net.Commons.AllureApi.AddAttachment
instead.AddScreenDiff - use Allure.Net.Commons.AllureApi.AddScreenDiff
instead.Allure.Net.Commons.Steps.CoreStepsHelper - use functions from
Allure.Net.Commons.AllureApi and Allure.Net.Commons.ExtendedApi instead.
There is no more need to use the separate Allure.XUnit.StepExtensions package.
You should uninstall it and use attributes from the
Allure.Xunit.Attributes.Steps namespace directly.
We rely on Harmony (which in turn uses MonoMod.Core) to:
Those features might not work in some rare circumstances, especially when testing the Release configuration. If you're affected, try switching to Debug as a workaround.
Issue #369 contains some additional details.
If you run your tests, but there is no Allure results directory (or it's empty),
xUnit.net may have preferred another reporter instead of allure.
You can force xUnit.net to select the allure reporter by providing it to the
runner. For xunit.runner.visualstudio, it could be done with the
xUnit.ReporterSwitch run setting:
dotnet test <test-project-name> -- xUnit.ReporterSwitch=allure
Alternatively, you may provide that option via a .runsettings file:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<xUnit>
<ReporterSwitch>allure</ReporterSwitch>
</xUnit>
</RunSettings>dotnet test -s <path-to-runsettings> <test-project-name>
If you run the tests via an IDE, refer to that IDE's documentation to figure out how to provide a
.runsettingsfile.
Check the test logs. If Allure.Xunit has run, the following entry should exist:
[xUnit.net 00:00:00.53] Allure.Xunit: Allure reporter enabled
If you don't see xUnit.net logs, try increasing the verbosity level to
normalordetailed:dotnet test --logger 'console;verbosity=normal'
xUnit.net only uses one reporter per run. But Allure Xunit allows you to bypass that limitation. Learn more here.
A CI-specific reporter might be enabled in addition to Allure Xunit in some CI environments like Azure DevOps or TeamCity. The result is that both reporters become available to run. In such cases, xUnit.net may select any of them.
To fix that, make sure that xUnit.net always picks Allure Xunit.