Skip to content

Commit

Permalink
Make VSTest runner work and enable html log
Browse files Browse the repository at this point in the history
The VSTest runner is now supposed to work with the /p:TestRunner=vstest
switch. Currently this is an opt-in but the desire is to get rid of
xunit.console completely and just use VSTest.
  • Loading branch information
ViktorHofer committed Mar 21, 2020
1 parent d7db838 commit df5c90a
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 20 deletions.
1 change: 0 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
<XUnitVersion>2.4.1</XUnitVersion>
<TraceEventVersion>2.0.5</TraceEventVersion>
<NewtonsoftJsonVersion>12.0.3</NewtonsoftJsonVersion>
<XUnitXmlTestLoggerVersion>2.1.26</XUnitXmlTestLoggerVersion>
<MoqVersion>4.12.0</MoqVersion>
<!-- Docs -->
<MicrosoftPrivateIntellisenseVersion>3.1.0-preview-20200129.1</MicrosoftPrivateIntellisenseVersion>
Expand Down
12 changes: 4 additions & 8 deletions eng/testing/xunit/vstest.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
<PropertyGroup>
<!-- Microsoft.Net.Test.Sdk brings a lot of satellite assemblies in. -->
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<TrxTestResultsName>testResults.trx</TrxTestResultsName>
<HtmlTestResultsName>testResults.html</HtmlTestResultsName>
<TestResultsName>$(HtmlTestResultsName)</TestResultsName>
<TestRunnerConfigPath>$(MSBuildThisFileDirectory)vstest.xunit.json</TestRunnerConfigPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitVersion)" />
<PackageReference Include="XunitXml.TestLogger" Version="$(XUnitXmlTestLoggerVersion)" />

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
</ItemGroup>

<ItemGroup>
<None Include="$(TestRunnerConfigPath)"
CopyToOutputDirectory="PreserveNewest"
Visible="false" />
</ItemGroup>
</Project>
10 changes: 7 additions & 3 deletions eng/testing/xunit/vstest.targets
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<Project>
<PropertyGroup>
<RunCommand>"$(RunScriptHost)"</RunCommand>
<RunCommand>"$(DotNetTool)"</RunCommand>
<RunCommand Condition="'$(ContinuousIntegrationBuild)' == 'true'">dotnet</RunCommand>
<RunArguments>test $(TargetFileName)</RunArguments>

<!-- CLI options -->
<RunArguments>$(RunArguments) --logger "xunit;LogFilePath=$(TestResultsName)"</RunArguments>
<RunArguments>$(RunArguments) --nologo</RunArguments>
<RunArguments>$(RunArguments) --logger "trx;LogFileName=$(TrxTestResultsName)"</RunArguments>
<RunArguments>$(RunArguments) --logger "html;LogFileName=$(HtmlTestResultsName)"</RunArguments>
<RunArguments>$(RunArguments) --framework $(TargetFramework)</RunArguments>
<RunArguments>$(RunArguments) --platform $(ArchGroup)</RunArguments>
<RunArguments Condition="'$(TestDisableParallelization)' != 'true'">$(RunArguments) --parallel</RunArguments>
Expand All @@ -27,6 +30,7 @@
<!-- RunConfiguration settings. -->
<RunSettingsOptions Condition="'$(TestDisableParallelization)' == 'true'">$(RunSettingsOptions) RunConfiguration.DisableParallelization=true</RunSettingsOptions>
<RunSettingsOptions Condition="'$(TestDisableAppDomain)' == 'true'">$(RunSettingsOptions) RunConfiguration.DisableAppDomain=true</RunSettingsOptions>
<RunArguments Condition="'$(RunSettingsOptions)' != ''">$(RunArguments) --(RunSettingsOptions)</RunArguments>
<RunSettingsOptions>$(RunSettingsOptions) RunConfiguration.DotNetHostPath="$(RunScriptHost)"</RunSettingsOptions>
<RunArguments>$(RunArguments) --$(RunSettingsOptions)</RunArguments>
</PropertyGroup>
</Project>
5 changes: 5 additions & 0 deletions eng/testing/xunit/vstest.xunit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"diagnosticMessages": false,
"longRunningTestSeconds": 120,
"shadowCopy": false
}
File renamed without changes.
2 changes: 2 additions & 0 deletions eng/testing/xunit/xunit.console.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project>
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TestResultsName>testResults.xml</TestResultsName>
<TestRunnerConfigPath>$(MSBuildThisFileDirectory)xunit.console.json</TestRunnerConfigPath>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 0 additions & 5 deletions eng/testing/xunit/xunit.console.targets
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
<!-- ResolveAssemblyReferences is the target that populates ReferenceCopyLocalPaths which is what is copied to output directory. -->
<Target Name="CopyRunnerToOutputDirectory" BeforeTargets="ResolveAssemblyReferences">
<ItemGroup>
<!-- Add the runner configuration file -->
<None Include="$(TestRunnerConfigPath)"
CopyToOutputDirectory="PreserveNewest"
Visible="false" />

<!-- Copy test runner to output directory -->
<None Include="$([System.IO.Path]::GetDirectoryName('$(XunitConsole472Path)'))\*"
Exclude="$([System.IO.Path]::GetDirectoryName('$(XunitConsole472Path)'))\xunit.console.*exe.config;$([System.IO.Path]::GetDirectoryName('$(XunitConsole472Path)'))\xunit.console.x86.exe"
Expand Down
2 changes: 0 additions & 2 deletions eng/testing/xunit/xunit.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<Project>
<PropertyGroup>
<TestRunner Condition="'$(TestRunner)' == ''">xunit.console</TestRunner>
<TestRunnerConfigPath>$(MSBuildThisFileDirectory)xunit.runner.json</TestRunnerConfigPath>
<TestResultsName>testResults.xml</TestResultsName>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions eng/testing/xunit/xunit.targets
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
<_withoutCategories Condition="'$(TargetOSCategory)' != ''">$(_withoutCategories);$(TargetOSCategory)</_withoutCategories>
</PropertyGroup>

<ItemGroup>
<None Include="$(TestRunnerConfigPath)"
Link="xunit.runner.json"
CopyToOutputDirectory="PreserveNewest"
Visible="false" />
</ItemGroup>

<Target Name="ValidateTargetOSCategory"
BeforeTargets="GenerateRunScript">
<Error Condition="'$(TargetOSCategory)' == ''"
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"rollForward": "major"
},
"tools": {
"dotnet": "5.0.100-preview.3.20168.11"
"dotnet": "5.0.100-preview.3.20170.6"
},
"native-tools": {
"cmake": "3.14.2",
Expand Down

0 comments on commit df5c90a

Please sign in to comment.