How can i use xunit (.net core) test results in jenkins? How can i use xunit (.net core) test results in jenkins? jenkins jenkins

How can i use xunit (.net core) test results in jenkins?


i struggled with this issue so i decided to share my answer based on my experience.

In order to use the test results, we need to output them into XML files that can be used later by a parser. The xml needs to be in the format that the parser knows how to read.

By default, when running dotnet test, it will output the test results into the console. In order to save those results into a file, we should use the "--logger" param. the logger param can accept a logger than will parse the test results into the desired format. in order to parse them into an xunit xml test files that can be used by tools like jenkins, we need to use an external logger named XunitXml.TestLogger. Now we can run the following command:

dotnet test --test-adapter-path:. --logger:xunit

that will export the results into a TestResults folder in each project you have.now we can use these files by any tool, like jenkins to parse those files. jenkins has a plugin named Xunit (how original) that does specifically that. it even lets you set some error thresholds etc.

Update: fegarding jenkins, i have found out that there are plugins that allow you to convert dot TRX results (that dotnet knows to export natively) to XUnit format. that might simplify it and save you that extra dependency. MSTest if one of those - https://wiki.jenkins.io/display/JENKINS/MSTest+Plugin