Xunit test fails with NU1701 - unit-testing

I try to get my unit tests for Xamarin to run, but fail to get it working. I added the following nuget packages to my project:
MSTest.TestAdapter
MSTest.TestFramework
xunit
I can see my unit tests in the list of tests. But when I start to run a single test I get the following message:
No test matches the given testcase filter FullyQualifiedName= ...
After researching a bit I found in the Build section this message:
Warning NU1701: Package 'MSTest.TestAdapter 1.4.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
How can I get my tests running?
EDIT: I uninstalled the MSTest Nuget from the project and got the following:
No test matches the given testcase filter
EDIT 2: The test looks like this:
using System;
using System.Collections.Generic;
using System.Text;
using App.Services;
using Xunit;
namespace App.Tests.Services
{
public class HelperTest
{
[Fact]
public void Encrypt_password_Test()
{
string password = "Helloworld";
string expectedResult = "";
string result = Helpers.Encrypt_password(password);
Assert.Equal(expectedResult, result);
}
}
}
I expect that the test will fail, because of the empty string.
The csproj file:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<NeutralLanguage>en-GB</NeutralLanguage>
<AssemblyName>App</AssemblyName>
<RootNamespace>App</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="SharpZipLib" Version="1.1.0" />
<PackageReference Include="sqlite-net-pcl" Version="1.5.231" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="Xamarin.Essentials" Version="1.2.0" />
<PackageReference Include="Xamarin.Forms" Version="4.1.0.581479" />
<PackageReference Include="Xamarin.Plugin.FilePicker" Version="2.1.18" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<XliffResource Include="MultilingualResources\App.de.xlf" />
</ItemGroup>
<ItemGroup>
<Compile Update="Localizations\AppResources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AppResources.resx</DependentUpon>
</Compile>
<Compile Update="Views\Login\NewProfilePage.xaml.cs">
<DependentUpon>NewProfilePage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Localizations\AppResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Views\Settings\AppSettings.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\Login\NewProfilePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\Settings\ProfilelistPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\Settings\ProfilePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\ProjectPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\Settings\SensorListPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\SensorTestPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\Settings\SettingsPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Tests\Projectlist\" />
<Folder Include="Tests\Settings\" />
</ItemGroup>
</Project>
I also created a example xunit test project. There I noticed that it uses netcoreapp2.1 as TargetFramework. When I change the TargetFramework in my app it makes it incompatible with Xamarin.

You nearly found the solution yourself. Indeed the reason the tests are not running is because netstandard target frameworks are not executable. netstandard is a contract, but it needs a runtime such as netcoreapp, the .NET Framework (net472 for example), Xamarin, or others. Tests were being discovered by static analysis, not by execution.
The usual way people write tests for their code is to put tests in a separate project. This also means when you ship your app to customers, the dlls they install don't have test code that will never run and just make the download larger for no reason.
So, create a xunit test project. Ideally it targets the same runtime that your app is going to run on, but I've never done any Xamarin development so I don't know if that's feasible, so maybe netcoreapp2.1 or netcoreapp2.2 is good enough. If you're using Visual Studio, add a project reference, otherwise edit the csproj and add <ProjectReference Include="../path/to/project.csproj" />.
If your production code has internal classes that you don't want to make public, then add the InternalsVisibleTo attribute to your production assembly, and it will be available just to your test assembly.

Related

Unable to run NUnit test in TestCentric whereas VS2019 works

I have created a NUnit3 project in VS2019, with the following properties and NuGet packages defined in the csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Platforms>x86</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Moq" Version="4.18.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
...
</ItemGroup>
</Project>
My test class is annotated with [TestFixture], and the testcases with [Test].
When I run the test in Visual Studio 2019 (from the Test Explorer), my tests run and succeed.
I have downloaded "TestCentric 2.0.0-alpha4"; when I load the test dll in there, it reports a "test count" of 1, but the "Run State" is NotRunnable. And therefore I cannot run the test in Test Centric; there is no logging whatsoever helping me here.
Has anyone encountered something similar, and can give me a clue on where I'm wrong?

How to add Google Mock to a project that already has Google Test?

I'm unit testing a Visual Studio project which has already been fully developed by the client. It came to us set up with Google test; it has many tests and we're adding more. I want to use Google Mock, which I know is part of Google Test, but I don't know how to get it to build correctly. Simply adding #include "gmock/gmock.h" doesn't work, so it's not simply actually included with gtest.
Currently, the project has a dependencies folder with a vendor_google_test_release folder, which as two subfolders: (the snippets are from the vsproj file)
vendor_google_test_release\h has what appears to be the contents of the GTest repo's googletest\include folder. The folder is included in the add'l include directories:
<AdditionalIncludeDirectories> ... $(ProjectDir)\..\..\dependencies\vendor_google_test_release\h\; ... </AdditionalIncludeDirectories>
vendor_google_test_release\lib\ has GoogleTestLib.lib && GoogleTestLib.pdb, which I think they built themselves. The lib file is included in the project:
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\dependencies\vendor_google_test_release\lib;$(ProjectDir)..\..\dependencies\vendor_google_mock_release\lib</AdditionalLibraryDirectories>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);GoogleTestLib.lib;WS2_32.lib</AdditionalDependencies>
</Link>
I've added a similar vendor_google_mock_release folder with a similar h folder (containing the contents of googlemock\include) and I've added that folder to the "additional include" folders which is where the gtest folders are included in the project.
When I add #include "gmock/gmock.h" to my code, I get a zillion errors coming from the gmock files.
I imagine what I need to do is build the google mock library, but I don't know how to do that. I'm pretty new to C++ and VS. I've followed a tutorial to build Google Test in a static library project, and added Google Mock to that as well, but it's not finding files it's looking for.
This is from the vsproj file of the attempted mock/test project:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>C:\Users\jtuzman\source\googletest-release-1.10.0\googletest\include;C:\Users\jtuzman\source\googletest-release-1.10.0\googlemock\include;$(IncludePath)</IncludePath>
</PropertyGroup>
...
...
...
<ItemGroup>
<ClCompile Include="..\..\..\googletest-release-1.10.0\googlemock\src\gmock-all.cc" />
<ClCompile Include="..\..\..\googletest-release-1.10.0\googlemock\src\gmock-cardinalities.cc" />
<ClCompile Include="..\..\..\googletest-release-1.10.0\googlemock\src\gmock-internal-utils.cc" />
<ClCompile Include="..\..\..\googletest-release-1.10.0\googlemock\src\gmock-matchers.cc" />
<ClCompile Include="..\..\..\googletest-release-1.10.0\googlemock\src\gmock-spec-builders.cc" />
<ClCompile Include="..\..\..\googletest-release-1.10.0\googlemock\src\gmock.cc" />
<ClCompile Include="..\..\..\googletest-release-1.10.0\googlemock\src\gmock_main.cc" />
</ItemGroup>
It's probably a relatively simple answer, I imagine. Thanks for help.

How to set .vcxproj to let MSBuild compile a dll

Above All
To save your time from reading a lot, Thanks to CristiFati and here is the answer:
If you use "Library" in "ConfigurationType" like me, you'll get an .obj file instead of .dll.
The right keyword is "DynamicLibrary" instead of "Library". That is:
<ConfigurationType>DynamicLibrary</ConfigurationType>
Then you'll have the .dll you want.
[supplement] From CMake Documents, thanks to Botje's guiding, it appears that a "Library" is actually like a sub-directory under the root project. Thus it's different with how dll work.
Short Story:
I need to compile a dll with MSbuild, without any IDE.
I followed instruction on Microsoft Doc to create app build project.
No webpage indicates how to create dll build project is found yet. Thus I edit .vcxproj according to similar google info.
BUILD SUCCESS!
But the result only contain a .obj file. No dll in sight.
Need help about how to modify a .vcxproj to build a dll.
Detailed Story:
I need to compile a dll.
My company didn't buy any commercial license thus I cannot use any IDE for this.
However MSBuild is safe to use.
I'm following this page to create a C++ project which could be compiled with MSBuild only.
https://learn.microsoft.com/en-us/cpp/build/walkthrough-using-msbuild-to-create-a-visual-cpp-project?view=vs-2017
You don't need actually read that page because I'll paste the project file below.
First, Following that page, I got this application type project file
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.default.props" />
<PropertyGroup>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<ClCompile Include="helloworld.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="helloworld.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Targets" />
</Project>
I tested the build. And got my .exe file successfully. And my helloworld.exe printed "HelloWorld" as predicted. Then...
Second, Following this page:
https://learn.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-dynamic-link-library-cpp?view=vs-2017
I'm sure the header and cpp file is good to go
#pragma once
#ifdef HELLOWORLD_EXPORTS
#define HELLOWORLD_API __declspec(dllexport)
#else
#define HELLOWORLD_API __declspec(dllimport)
#endif
extern "C" HELLOWORLD_API void helloworld();
Third, Switch this project from application mode to library mode...
Actually I'm not sure how to do this. So I googled some info and try to do what they did.
I change the Debug mode to Release mode.
Then change the Application output to Library.
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.default.props" />
<PropertyGroup>
<ConfigurationType>Library</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<ClCompile Include="helloworld.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="helloworld.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Targets" />
</Project>
Finally, I let msbuild do its work:
msbuild helloworld.vcxproj /p:configuration=Release
And the build is success!
But when I head to Release folder under my root directory, I find only a "helloworld.obj" file and a "vc141.pdb" along a folder names "helloworld.tlog".
Well this is not right. I think the right result will be a "helloworld.dll" in here.
So, that should be my .vcxproj file's problem I guess.
So, could anybody kindly give a guide for creating a dll project from scratch?
Thanks!
Although using the IDE is prohibited by licensing purposes, listing [MS.Docs]: Walkthrough: Create and use your own Dynamic Link Library (C++) anyway.
The keypoint is:
3. From the filtered list of project types, select Dynamic-link Library (DLL), and then choose Next.
Behind the scenes, that maps to: [MS.Docs]: ConfigurationTypes Enum:
Fields
typeApplication             1      Application (.exe)
typeDynamicLibrary      2      Dynamic Library (.dll)
typeGeneric                 10      Makefile, displays makefile toolset (NMake)
typeStaticLibrary           4      Static Library (.dll)
typeUnknown                0      Utility
Translated to .vcxproj structure, the ConfigurationType node:
<ConfigurationType>Application</ConfigurationType>
should be converted to:
<ConfigurationType>DynamicLibrary</ConfigurationType>
But, as (#Botje's) comments rightly pointed out, you should move towards free build tools (there are a number of alternatives, and CMake seems to be the best one).

Need guidance on packaging QT Desktop Application into AppX format using Visual Studio 17

I am trying to create an appx/appxupload package for my QT GUI application so that it can be published to the Windows Store. Here are the list of steps I followed to generate an appx package:
Generate a Visual Studio project file using my QT .pro file by using the qmake -tp vc command in the directory containing my .pro file. I have used the x86 msvc-2017 kit in QT
Opened the .vcproj file using Visual Studio 2017 ,Version 15.9.10 and built the project to check for any errors.
Added a new project Windows Application Packaging Project (Visual C++) to the same Visual Studio solution.
Added my QT project (now converted to Visual Studio project) as a reference to Applications in my new Packaging project
Added all the Visual Assets, app name and other configuration settings in the Designer mode and then built the project
Package the application to upload to Windows Store
When, I try to install and run the application, I get an error saying : This application failed to start because it could not find or load the Qt platform plugin "windows" in "".. All the QT plugins are present in the installation folder, however my application exe file is present inside an another folder in the installation directory like AppName\AppName.exe. If I copy the AppName.exe outside the AppName folder and run, the app runs fine.
I went through the various xml files and I see under Application section, Executable = "AppName\AppName.exe" instead of Executable = AppName.exe. I believe there is a configuration setting where one can configure the Application target path. If the exe file is at the same level as that of all the other QT dll's, the app will run fine without errors.
Can someone please help resolve this issue?
Thanks
The Package.appxmanifest generated by Visual Studio
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap">
<Identity Name="CybernetyxTechnikPvt.Ltd.AirMindThinker" Publisher="CN=FD00F14F-4E0A-4328-8B66-60A5777EDBFE" Version="1.0.24.0" />
<Properties>
<DisplayName>AirMind Thinker</DisplayName>
<PublisherDisplayName>Cybernetyx Technik Pvt. Ltd.</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements DisplayName="AirMind Thinker" Description="AirMind Thinker Application" BackgroundColor="transparent" Square150x150Logo="Images\Square150x150Logo.png" Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" Square310x310Logo="Images\LargeTile.png" Square71x71Logo="Images\SmallTile.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
This is the AppxManifest.xml generated in the output folder (bin/x86/Release/)
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap build" xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build">
<!--
THIS PACKAGE MANIFEST FILE IS GENERATED BY THE BUILD PROCESS.
Changes to this file will be lost when it is regenerated. To correct errors in this file, edit the source .appxmanifest file.
For more information on package manifest files, see http://go.microsoft.com/fwlink/?LinkID=241727
-->
<Identity Name="CybernetyxTechnikPvt.Ltd.AirMindThinker" Publisher="CN=FD00F14F-4E0A-4328-8B66-60A5777EDBFE" Version="1.0.24.0" ProcessorArchitecture="x86" />
<Properties>
<DisplayName>AirMind Thinker</DisplayName>
<PublisherDisplayName>Cybernetyx Technik Pvt. Ltd.</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.14393.0" MaxVersionTested="10.0.17763.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.17763.0" />
<PackageDependency Name="Microsoft.VCLibs.140.00.UWPDesktop" MinVersion="14.0.26905.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
</Dependencies>
<Resources>
<Resource Language="EN-US" />
</Resources>
<Applications>
<Application Id="App" Executable="AirMindThinker\AirMindThinker.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="AirMind Thinker" Description="AirMind Thinker Application" BackgroundColor="transparent" Square150x150Logo="Images\Square150x150Logo.png" Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" Square310x310Logo="Images\LargeTile.png" Square71x71Logo="Images\SmallTile.png"></uap:DefaultTile>
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
<build:Metadata>
<build:Item Name="Microsoft.Build.DesktopBridge.Tasks.dll" Version="4.6.30319.200" />
<build:Item Name="TargetFrameworkMoniker" Value=".NETCore,Version=v5.0" />
<build:Item Name="VisualStudio" Version="15.0" />
<build:Item Name="VisualStudioEdition" Value="Microsoft Visual Studio Community 2017" />
<build:Item Name="OperatingSystem" Version="10.0.18362.1 (WinBuild.160101.0800)" />
<build:Item Name="Microsoft.Build.AppxPackage.dll" Version="15.0.28307.104" />
<build:Item Name="ProjectGUID" Value="e995a5ab-e99d-4e1c-864d-a5fbbfc73ceb" />
<build:Item Name="MakePri.exe" Version="10.0.17763.132 (WinBuild.160101.0800)" />
</build:Metadata>
</Package>

Unit Tests are never discovered

I have the following solution in Visual Studio 2017 Update 3 preview, which consists of a Xamarin.Forms project as NetStandard1.4 and a NetStandard1.4 dotnet Core Services.API project and a NetStandard1.6 dotnet Core unit test project.
The Unit Test project references the services project only. The csproj file looks like this, with the MSTest framework added for unit testing. The issue though is that the tests are never discovered.
csproj
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
<AssemblyName>FloatSink.Services.Api.Tests</AssemblyName>
<RootNamespace>FloatSink.Services</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0"></PackageReference>
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.1.17" />
<PackageReference Include="MSTest.TestFramework" Version="1.1.17" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Services.API\Services.API.csproj" />
</ItemGroup>
Unit Test class
[TestClass]
public class AppBuilderTests
{
private const string DebugBuild = "Debug build";
private const string ReleaseBuild = "Release build";
/// <summary>
/// Test that the ToString() method returns the string we sent into the constructor
/// </summary>
[TestMethod]
public void ToStringReturnsStringFromCtor()
{
// Act
var build = new AppBuild(DebugBuild);
// Assert
Assert.AreEqual(DebugBuild, build.ToString());
}
}
Finally this is the test output when I build and select Run All from the Test Explorer (which is empty).
[5/26/2017 6:38:23 PM Informational] ------ Load Playlist started ------
[5/26/2017 6:38:23 PM Informational] ========== Load Playlist finished (0:00:00.004501) ==========
[5/26/2017 6:38:24 PM Informational] ------ Discover test started ------
[5/26/2017 6:38:25 PM Informational] ========== Discover test finished: 0
found (0:00:00.5716028) ==========
Why won't the MSTest unit tests show up in the Test Explorer and allow me to discover/run them?
Update
I changed the debug type from Full to portable and I've also tried this with xUnit and have the same issue. So this isn't specific to MSTest.
csproj with xUnit
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
<AssemblyName>FloatSink.Services.Api.Tests</AssemblyName>
<RootNamespace>FloatSink.Services</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>portable</DebugType>
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Services.API\Services.API.csproj" />
</ItemGroup>
</Project>
The problem is that your TargetFramework is set to a .NET Standard version.
Although test projects look like libraries, they have more characteristics of a runnable output - the 15.0.0 test sdk even changes the output type to Exe to trigger generation of assets needed to run the tests. (In 2.0 / 15.3.0 this will change to a new HasRuntimeOutput property).
The fix here is to change the TargetFramework to either some version of net* or netcoreapp* depending on what framework you want to run the tests on.