Getting the tSQLt Run Adapter working in Visual Studio 2017

Last year I heard about the tSQLt test Adapter for Visual Studio from Ed Elliot. I’ve been wanting to try it, but various items got in the way. Finally I had the chance to play and it worked well in Visual Studio 2015, but I needed it in VS 2017. Fortunately Ed had a tSQLt Run Adapter beta for Visual Studio 2017, but I had a few issues. This is a debugging post.

I downloaded the file and ran setup. Since this can cause issues with VS 2015, I unchecked that box. Unfortunately, I think I messed up my VS 2015 project. No matter, we’ll forge on.

I had a Readyroll project where I was doing some work. In following some of the work at Redgate from a developer, I set up a new test project according to the tutorial. I got through and no tests.

Hmmm.

The .runsettings file is set in the root of my solution, as shown here:

The contents are:

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <TestRunParameters>
    <Parameter name="TestDatabaseConnectionString" value="Data Source=.\SQL2016;Initial Catalog=PartsUnlimitedDB;Integrated Security=True;" />
    <Parameter name="IncludePath" value="Tests" />
  </TestRunParameters>
</RunSettings>

My local instance is .\SQL2016, a named instance, and I have a PartsUnlimitedDB database on this instance.

Here the file is selected:

When I run all tests, I get this:

I heard from Ed that I needed to have the name “tests” in the filename, so I changed that. Here’s the test and the file name

Now I see my tests in the test explorer. Success!

Just to check a few things, let’s try another file. Here I’ll use a shorter name, though still descriptive.

And again, success.

That felt strange, but some back and forth with Ed showed me that the IncludeFile filter in the .runsettings file needs to be set to some value. In the default file I used, it’s set to “tests”. If I change it to test, and include a new test, then I things still work:

About way0utwest

Editor, SQLServerCentral
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

2 Responses to Getting the tSQLt Run Adapter working in Visual Studio 2017

  1. Ed Elliott says:

    Now this was a thrilling ride 🙂

    If you remove the include filter element it isn’t used, it is just there for larger projects which would take quite a lot of time to parse the entire thing when we are just interested, normally, in a folder under a test directory.

    Ed

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s