André Carlucci

Skeptic .net development

Continuous testing for .net core

Visual Studio 2017 is already there and it’s awesome.
One of the best features I’ve seen is the Live Unit Testing. The bad news is: it does not yet support .net core :(

It’s not the same, but one thing you can use to automatically run your tests every time you change some file is the command line dotnet watch.

Let’s create one example:

Create your lib project:

Create your test project:

Add reference to your lib project

Open your test.csproj and add this section anywhere:

Add the DotNet Watcher tool to your test project

Still with your test.csproj open, add another item group:

Save and type:

Finally, start your continuous tests

Note the message that it is waiting for file changes :)

Modify your test/lib projects and check the results

In your test/UnitTest1.cs:

And your lib/Class1.cs

Save both and watch your test fail :)

Fix your test

In lib/Class1.cs, change the result:

And watch your cmd:


Filtering your tests

You don’t need to run all tests all the time. You can filter them by DisplayName, FullyQualifiedName and Traits.

Also, these operators are allowed: =, != and ~ (contains).


More information about filtering tests here.

Happy testing :)