Skip to content

Commit 82f520b

Browse files
committed
Create general TestAssembly target
- rename WebStack.xunit.targets -> WebStack.testing.targets - rename `Xunit` target -> `TestAssembly` - move `dotnet vstest` use into new target - handle exit codes more consistently
1 parent 8ee67e0 commit 82f520b

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

Runtime.msbuild

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,32 +102,30 @@
102102
<Target Name="RunTests" DependsOnTargets="CheckSkipStrongNames">
103103
<ItemGroup>
104104
<_TestDLLsXunit Include="bin\$(Configuration)\test\*.Test.dll" />
105-
<_TestDLLsXunit Include="bin\$(Configuration)\test\*\net4*\*.Test.dll" Condition="'$(BuildPortable)' == 'true'" />
106-
<_XunitProject Include="tools\WebStack.xunit.targets">
107-
<Properties>TestAssembly=%(_TestDLLsXunit.FullPath);XmlPath=$(TestResultsDirectory)%(_TestDLLsXunit.FileName)-XunitResults.xml</Properties>
105+
<_TestDLLsXunit Include="bin\$(Configuration)\test\*\net4*\*.Test.dll"
106+
Condition=" '$(BuildPortable)' == 'true' " />
107+
<_XunitProject Include="tools\WebStack.testing.targets">
108+
<Properties>TestAssembly=%(_TestDLLsXunit.FullPath);
109+
XmlPath=$(TestResultsDirectory)%(_TestDLLsXunit.FileName)-XunitResults.xml</Properties>
108110
</_XunitProject>
109111

110-
<_VSTestDLLs Include="bin\$(Configuration)\test\*\netcoreapp*\*.Test.dll" />
111-
</ItemGroup>
112-
<ItemGroup>
113-
<_VSTestDLLs>
114-
<TestResultsPath>$(TestResultsDirectory)%(FileName)-NetCoreApp-XunitResults.xml</TestResultsPath>
115-
</_VSTestDLLs>
112+
<_VSTestDLLs Include="bin\$(Configuration)\test\*\netcoreapp*\*.Test.dll"
113+
Condition=" '$(BuildPortable)' == 'true' "/>
114+
<_XunitProject Include="tools\WebStack.testing.targets"
115+
Condition=" '$(BuildPortable)' == 'true' ">
116+
<Properties>TestAssembly=%(_VSTestDLLs.FullPath);
117+
XmlPath=$(TestResultsDirectory)%(_VSTestDLLs.FileName)-NetCoreApp-XunitResults.xml;
118+
UseVSTest=true</Properties>
119+
</_XunitProject>
116120
</ItemGroup>
117121

118122
<!-- Recreate the test results directory so that print summary doesn't run on old test results. -->
119123
<RemoveDir Directories="$(TestResultsDirectory)" />
120124
<MakeDir Directories="$(TestResultsDirectory)" />
121125

122-
<MSBuild Projects="@(_XunitProject)" BuildInParallel="$(TestInParallel)" Targets="Xunit">
126+
<MSBuild Projects="@(_XunitProject)" BuildInParallel="$(TestInParallel)" Targets="TestAssembly">
123127
<Output TaskParameter="TargetOutputs" ItemName="_ExitCodes" />
124128
</MSBuild>
125-
126-
<Exec Command="dotnet vstest @(_VSTestDLLs) --logger:&quot;xunit;LogFilePath=%(_VSTestDLLs.TestResultsPath)&quot;"
127-
Condition=" '$(BuildPortable)' == 'true' "
128-
IgnoreExitCode="true">
129-
<Output TaskParameter="ExitCode" ItemName="_VSTestErrorCode" />
130-
</Exec>
131129
</Target>
132130

133131
<Target Name="CheckSkipStrongNames" DependsOnTargets="RestoreSkipStrongNames">

tools/WebStack.xunit.targets renamed to tools/WebStack.testing.targets

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,19 @@
55
-->
66
<Import Project="..\packages\**\xunit.runner.msbuild.props"/>
77

8-
<Target Name="Xunit" Returns="@(_ExitCodes)">
9-
<xunit Assemblies="$(TestAssembly)" Xml="$(XmlPath)" IgnoreFailures="true">
8+
<Target Name="TestAssembly" Returns="@(_ExitCodes)">
9+
<xunit Assemblies="$(TestAssembly)"
10+
Condition=" '$(UseVSTest)' != 'true' "
11+
IgnoreFailures="true"
12+
Xml="$(XmlPath)">
1013
<Output TaskParameter="ExitCode" PropertyName="_ExitCode" />
1114
</xunit>
15+
<Exec Command="dotnet vstest $(TestAssembly) --logger:&quot;xunit;LogFilePath=$(XmlPath)&quot;"
16+
Condition=" '$(UseVSTest)' == 'true' "
17+
IgnoreExitCode="true"
18+
IgnoreStandardErrorWarningFormat="true">
19+
<Output TaskParameter="ExitCode" PropertyName="_ExitCode" />
20+
</Exec>
1221

1322
<ItemGroup>
1423
<_ExitCodes Include="$(TestAssembly)" Code="$(_ExitCode)" />

0 commit comments

Comments
 (0)