Skip to content

Add UnitTestContainer project capability - #440

Merged
Satya Madala (smadala) merged 11 commits into
masterfrom
UTCCapability
Feb 17, 2017
Merged

Satya Madala (smadala) merged 11 commits into
masterfrom
UTCCapability

Conversation

@tmat

@tmat Tomáš Matoušek (tmat) commented Feb 3, 2017 •

Copy link
Copy Markdown
Member

This capability is used to detect test projects.

Related issue: #394

@msftclas

Hi Tomáš Matoušek (@tmat), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Tomas Matousek). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@tmat

Copy link
Copy Markdown
Member Author
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this props file is only dropped into the netcoreapp folder of the package - so if the unit test is targeting net46, it won't have this capability. There's a different issue for which I think there should just be one props file - so maybe this is fine if that issue is fixed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made changes to copy same props file for net45 and netcore.

@tmat

Copy link
Copy Markdown
Member Author

OK to merge?

@sbaid

sbaid commented Feb 8, 2017

Copy link
Copy Markdown
Contributor

Tomáš Matoušek (@tmat) we can add this capability into the mstestv2 nuget & raise PR for xunit as well. That is better since it will address other projects as well - like u said. comments?

secondly - there is another build conditional support for test project that Nate McMaster (@natemcmaster) is referring in #441 - we should rationalize whether to add separate property like IsTestProject or simply depend on the project capability.

@tmat

Copy link
Copy Markdown
Member Author

sbaid Actually, as I learned the legacy projects doesn't support capabilities. Long term it's better but I believe we have telemetry reasons to add it to the test sdk. Srivatsn Narayanan (@srivatsn) for details.

@natemcmaster

Copy link
Copy Markdown
Contributor

As I originally proposed in #441, would you also consider adding a global static property in addition to the addition of the ProjectCapability?

ProjectCapability is fine for VS purposes, but it's a bit cumbersome to program with. MSBuild developers would have to know MSBuild and the expected values in ProjectCapability well enough to know they need to write something like this to determine if a project is a test project:

<ItemGroup>
  <_FilteredCapabilities Include="ProjectCapabilities" Condition="'%(Identity)'=='UnitTestContainer'" />
</ItemGroup>
<PropertyGroup>
  <IsTestProject Condition="@(_FilteredCapabilities -> Count()) &gt; 0">true</IsTestProject>
</PropertyGroup>

It would be nice the SDK could just define <IsTestProject>true</IsTestProject>.

@srivatsn

Copy link
Copy Markdown

Nate McMaster (@natemcmaster)'s point is valid - it's easier to do a property check. However VS also needs the capability as that's the common mechanism that the project system uses to light up components. I think having both is fine as well.

@sbaid

sbaid commented Feb 9, 2017

Copy link
Copy Markdown
Contributor

Srivatsn Narayanan (@srivatsn) Tomáš Matoušek (@tmat) to close on the project capability - if we close on the name as TestContainer 1) This link seem to suggest a process to add new project capability. Can you pl add the right folks here? 2) will this work only for CPS projects and hence only for .NET core projects? 3) if yes - for desktop projects - is there a way to address it - It will LUT & in general scoping test discovery to not scan all projects Gen Lu (@genlu)

pl note that test.sdk is only included in .net core templates - not in desktop templates.

@sbaid

sbaid commented Feb 9, 2017

Copy link
Copy Markdown
Contributor

Tomáš Matoušek (@tmat) codito do u have any comments on adding IsTestProject to sdk props?

@tmat

Copy link
Copy Markdown
Member Author

sbaid

  1. The name is actually UnitTestContainer, not TestContainer. The capability has already been added.
  2. IsHierarchy API works only for CPS projects, but the capability item can be added to any project.
  3. We check for capability and also for well-known test framework references, to make LUT work for xunit, nunit and mstest in v1.0.
@tmat

Copy link
Copy Markdown
Member Author

IsTestProject is fine.

@sbaid

sbaid commented Feb 9, 2017

Copy link
Copy Markdown
Contributor

should we not name it TestContainer because test projects in vs work for unit testing as well as functional testing?

@tmat

Tomáš Matoušek (tmat) commented Feb 9, 2017 •

Copy link
Copy Markdown
Member Author

We are already using the name in LUT. I wonder if it would be useful to have both UnitTestContainer and TestContainer. The distinction is interesting for LUT, since we would likely want to ignore functional tests. Of course it's completely up to the user to make the distinction.

@tmat

Copy link
Copy Markdown
Member Author

If we add both we should also have IsTestProject and IsUnitTestProject.

@tmat

Copy link
Copy Markdown
Member Author
@sbaid

sbaid commented Feb 9, 2017

Copy link
Copy Markdown
Contributor

pvlakshm (@pvlakshm) @piotrpMSFT looping in

@sbaid

sbaid commented Feb 9, 2017 •

Copy link
Copy Markdown
Contributor

I think we should add TestContainer & IsTestProject by default and let the user flag unit test capability by adding himself and not add by default. We are shipping only one set of templates and marking them by default unit test will not help since user may write functional tests in them & not change the defaults.

@tmat

Copy link
Copy Markdown
Member Author

I guess it would be ok to change the name to TestContainer, since LUT doesn't work for CPS based projects yet anyways. So we can change the code in LUT that checks for the capability without breaking anything.

@bradwilson

Copy link
Copy Markdown

sbaid said:

we can add this capability into the mstestv2 nuget & raise PR for xunit as well.

This seems like it belongs in Microsoft.NET.Test.Sdk, not the test frameworks. We don't know what this capability is, and we certainly don't directly provide it. I would reject the PR to xUnit.net for this.

@codito

codito commented Feb 12, 2017

Copy link
Copy Markdown
Contributor

sbaid wrote:

I think we should add TestContainer & IsTestProject by default

+1. It will be consistent, TestContainer term is already used in Testwindow extensibility.

The types of test projects are numerous (functional test, load test, generic test, ordered test etc..). Each individual template should provide additional distinctions (e.g. CUIT should provide IsFunctionalTest etc.). Default unit testing templates don't need to add anything.

@sbaid

sbaid commented Feb 13, 2017

Copy link
Copy Markdown
Contributor

Tomáš Matoušek (@tmat) Brad Wilson (@bradwilson) we can add this in Microsoft.NET.Test.Sdk for .net core. Do u have a suggestion how to address this for desktop test projects? currently there is no consistent way to identify test projects.

  1. There is test guid for projects created using inbox UT templates.
  2. user can create classlibrary project & add his framework of choice mstest,xunit, nunit - now this is a test project.
@smadala

Copy link
Copy Markdown
Contributor

Validation matrix
validation_matrix

Comment thread src/Microsoft.NET.Test.Sdk.targets Outdated
<GenerateProgramFile Condition="'$(GenerateProgramFile)' == ''">true</GenerateProgramFile>
</PropertyGroup>

<!-- Output type for dotnet core test project should be exe. For full CLR it is Library by default. -->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a workaround for sdk bug. Can you please mention the bug here for tracking?

I guess the only caveat is all comparisons in the test csproj will return $(OutputType) to be Library since that's the default, and the targets are imported at the end.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added issues link.

@codito

codito commented Feb 17, 2017

Copy link
Copy Markdown
Contributor

LGTM

<GeneratedProgramFile Condition="'$(GeneratedProgramFile)' ==''">$(IntermediateOutputPath)$(MSBuildProjectName).Program$(DefaultLanguageSourceExtension)</GeneratedProgramFile>
<GenerateProgramFile Condition="'$(GenerateProgramFile)' == ''">true</GenerateProgramFile>
</PropertyGroup>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the bug reference (dotnet/project-system#268) here. It will tell us why did we moved OutputType from props file target file. In future once the bug will get fixed we will revert it back.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@smadala
Satya Madala (smadala) merged commit 26ae9ea into master Feb 17, 2017
@smadala
Satya Madala (smadala) deleted the UTCCapability branch February 17, 2017 05:27
Satya Madala (smadala) pushed a commit to smadala/vstest that referenced this pull request Feb 17, 2017
…ft#440)

* Add TestContainer Capability and IsTestProject prop.

* Add Issues reference.
Satya Madala (smadala) added a commit that referenced this pull request Feb 17, 2017
…514)

* Add TestContainer Capability and IsTestProject prop.

* Add Issues reference.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectCapability Include="TestContainer" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should be putting this in the packages themselves, I can install xUnit in a random project that doesn't have to be test project (in fact Brad mentioned they are enabling that in their new dotnet xunit runner).

We should get xUnit, NUnit, etc to all mark themselves as a TestContainer

@sbaid sbaid Apr 13, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

David Kean (@davkean) this was discussed earlier. Pl refer comments on feb 12th.
Brad Wilson (@bradwilson) it will be good to add TestContainer projectcapability in the xunit.runner.visualstudio nuget package. It will help .NET Fx (Full CLR) projects. For dotnet projects - Microsoft.Net.Test.Sdk is adding it. Can this be done for 2.3 release?

Brad Wilson (bradwilson) added a commit to xunit/visualstudio.xunit that referenced this pull request Apr 27, 2017
Patrick Lioi (plioi) added a commit to fixie/fixie that referenced this pull request Aug 18, 2017
…jects, mark test projects with the IsTestProject property and include the TestContainer project capability. See microsoft/vstest#440
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

10 participants