MSBuild.SolutionSdk icon indicating copy to clipboard operation
MSBuild.SolutionSdk copied to clipboard

VSTest Target

Open smack0007 opened this issue 6 years ago • 2 comments

In my SnowShovel project I'm using an slnproj file to run my tests:

  <Target Name="VSTest">
    <ItemGroup>
      <TestProjects Include="tests/**/*.csproj" />
    </ItemGroup>
    <MSBuild Projects="@(TestProjects)" Targets="VSTest" />
  </Target>

Tests can then be executed with the dotnet cli:

dotnet test SnowShovel.slnproj

I feel like this should be in the box. I'm willing to create a pull request if you can assist me in how to test changes in the project.

smack0007 avatar Feb 09 '19 17:02 smack0007

Good idea, the VSTest target should be in the box indeed. However I don't want to force a convention by having to put the test projects in a tests/ folder and I'd prefer if it just worked without having to specify the test projects.

All test project define the $(IsTestProject) msbuild property, I think the VSTest target could automagically include only these projects.

I have started a refactoring to use the msbuild sdk, this allows to query the csproj properties and make this feature possible.

I should be able to find some time in a couple of weeks to finish the refactoring and implement this feature, I'll leave the issue open for tracking.

Thanks for the proposal

JeffCyr avatar Feb 13 '19 18:02 JeffCyr

Cool, I didn't know about this property $(IsTestProject). If you can use that to identify the test projects then that is better than enforcing the convention that all test projects are under the tests directory.

smack0007 avatar Feb 14 '19 08:02 smack0007