Target and Visualize Results of Multiple Frameworks in .Net Unit Tests with Jenskins CI

Georg Dangl by Georg Dangl in Continuous Integration Monday, October 02, 2017

Monday, October 02, 2017

Target and Visualize Results of Multiple Frameworks in .Net Unit Tests with Jenskins CI
Posted in DotNet Jenkins xUnit

In the example project, the unit test project is configured with multiple TargetFrameworks. This is to ensure that tests are being repeated on all target platforms and catch differing runtime behavior early. There are a few cases where there are differences, so it should be best practice for you to run your tests in as many configurations as possible. See the project file below how to set up such a project.

With xUnit and Jenkins, you ideally have a configuration that tests your code on every commit, so you'll have test results available that look like this:

 Test results before

When you take a look at the detailed results, you see that your tests are repeated for every target framework. This is great, since it means that all tests are actually run, but you're not getting information about the framework in which a failure occurred. You've just got the same test repeated, with the exact same name. Luckily, if you launch dotnet xunit and don't specify an explicit framework, it will by default run tests across all specified frameworks and amend the output files with the framework name.

This makes it easy to add information about the test framework before publishing in Jenkins with the xUnit plugin: Get the framework name from the test results filename and prepend it to the type attribute of every run test case. The above test script calls into a second helper script to do just that:

Suddenly, you have detailed information about every run test case and can much easier identify problems and reproduce them when they arise:

 Test results after

Happy testing!


Share this post


comments powered by Disqus

Dangl.Blog();
// Just 💗 Coding

Social Links