This is a reminder to myself more than anything else.
It is not often that I get to greenfield a new project. Most of the time, the solution already exists, and I start hacking away at it in my normal enthusiastic fashion.
I am a big fan of xUnit as a unit-testing framework.
Not that it has any particular advantages imho, but rather, at the time I was nosing into various test frameworks, xUnit was the only one that supported everything you threw at it; Xamarin projects, .Net Core projects etc. So I picked up its syntax, and stuck with it as my preference to day’s date.
Whenever I start a new solution in Visual Studio, I typically include references to a handful of the xUnit nuget packages in my unit-testing projects:
I am also a huge fan of the feature “Live Unit testing” in Visual Studio. The responsiveness of writing unit-tests and immediately see them fail/pass as you hit save is just so powerful! Once you try it, you’ll never go back. Honest!
Anyways, if you do this, and run the code, you’ll get an error once you activate live unit testing in Visual Studio. The error message comes from XUnit which claims (among other things) the following:
“Exception filtering tests: No tests matched the filter because it contains one or more properties that are not valid (TestCategory, Category)“
And then of course, you resort to GDD (Google-Driven Development), upon which you’ll find dozens of articles with workarounds for this issue, most of them recommend creating a dummy unit-test class with the necessary categories added to them.
BUT, there is another solution that works fine with .Net Framework versions as well as .Net Core (tested upto version 3.0):
Simply add the following package from nuget:
Once this package is added to the solution, the Live Unit Testing immediately starts working, and life becomes good again.
As I mentioned, this is a reminder to myself, mostly, but I figured I’d post it here, in case more of you struggle with the same issue 🙂