Using allure with xUnit

3.5k views Asked by At

Did anyone tried to use Allure reports for xUnit tests solution? I'm in doubts because there is no xUnit in the list of supported adapters(https://github.com/allure-framework/allure-core/wiki#gathering-information-about-tests). I have installed Allure teamcity plugin but there is no any allure output in the artifacts. If someone used Allure teamcity plugin with xUnit please explain how to set it up. Thanks in advance.

3

There are 3 answers

0
Ivan On BEST ANSWER

Allure support confirmed that there is no xUnit support for now. So the only way is to create custom adapter for xUnit

1
Ivan Shumakov On

To display xUnit tests on .NET Core in allure reports you can use this Open Source library. It's custom adapter. This library based on Allure.Commons. It's project with examples using this library: https://github.com/TinkoffCreditSystems/Allure.XUnit/tree/master/src/Examples

You must mark you test methods by this library attributes. Instead [Fact()] attribute you must use [AllureXUnit()] attribute, and you can use other unrequired attributes for markup html-report. All exists attributes were descripted in library Readme.

Than you must run tests by command:

dotnet test <PathToYourProject>

After that json files will be generated in directory which you specify in "directory" field of allureConfig.json. You can build html report by command allure serve or by allure plugins in TeamCity from this json files.

0
Megha On

Allure2 do support xunit project. It does not require a adapter but you can simply generate allure reports from xunit xml reports. Steps taken for .netcore2 xunit test project.

  1. Generated output xunit xml report with command: dotnet test --logger:trx
  2. Generated Allure report with command: allure serve /home/path/to/project/target/surefire-reports/ (Refer docs to install allure commandline - docs.qameta.io/allure/latest/#_installing_a_commandline)