UWP, .NET Standard, .NET Core, and Unit Testing (Oh My!)

tl;dr A UWP app can reference a .NET Standard 2.0 Class Library, and a .NET Core 2.1 Console Application can run unit tests against that .NET Standard Class Library.

I’m working on a UWP app and needed to write unit tests for some non-UI logic. There are a myriad of project types to pick from in Visual Studio these days, and I picked a few of the wrong types at first. It turns out that a .NET Standard 2.0 Class Library works well for housing this logic.

To test your .NET Standard 2.0 Class Library, you can create an nUnit (or xUnit or MSTest) Project (.NET Core) per the screenshot below.


Project Type for Testing .NET Standard 2.0 Class Library

In summary, I have a Universal Windows (UWP) app and a  nUnit Test Project (.NET Core) that both reference a .NET Standard 2.0 class library containing non-UI logic for the app to consume — and this works fine. Phew!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s