Besides that, the most interesting thing is the method display name options, where you can find options to:
eq becomes =
);To enable them, go to the xunit.runner.json
file and add a new key.
"methodDisplayOptions": "replaceUnderscoreWithSpace,useOperatorMonikers"
So, for the following tests:
public class DisplayNameTests
{
[Fact]
public void Given10_WhenMultiplyBy2_ThenGet20()
{
var result = 10 * 2;
result.Should().Be(20);
}
[Fact]
public void Is_20_gt_10()
{
20.Should().BeGreaterThan(10);
}
}
Once you run the tests, you will see:
Instead of:
I don't say you must use this, but knowing that these features exist may be helpful to improve the readability of your tests when analysing the results. In some cases, the existing conventions may help achieve better results, like if you are using Snake casing, enabling the "replaceUnderscoreWithSpace" is a quick improvement.
Now it's time to take a look into your codebase, look into the existing configuration options, and you may find a quick win.
🔗 You can find the source code used here.
I hope that this was useful! To get more tips like this, follow me on Twitter (@gsferreira) and let's keep in touch!