-
Notifications
You must be signed in to change notification settings - Fork 720
Migrate from VSTest to Microsoft.Testing.Platform #8498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e427f13
d09bcd5
58a546a
3e4ccd1
f1a32f2
8bd7802
c179724
d82894a
04dfe12
6cd862b
3b40316
f7e6994
45fd316
e5458d1
519188d
cb6cd28
29087a6
5f0f004
ce7e735
e0b800c
c44896a
f15a1c1
d3795eb
e440ddf
f33dc66
688b6d6
a8b0cd6
cc26956
11e89e4
5ea5eac
d10e168
c54564b
8f77898
4ba7d9a
5201f07
7817820
4a3a753
42735e0
d414db6
5f89e7d
ec6cacb
5958a02
ddf0755
8e5e3db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. --> | ||
danmoseley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <Project> | ||
|
|
||
| <Target Name="RunTests" | ||
| Outputs="%(TestToRun.ResultsStdOutPath)" | ||
| Condition="'@(TestToRun)' != ''"> | ||
| <Telemetry EventName="NETCORE_ENGINEERING_TELEMETRY" EventData="Category=Test" /> | ||
|
|
||
| <PropertyGroup> | ||
| <_TestResultDirectory>$([System.IO.Path]::GetDirectoryName('%(TestToRun.ResultsTrxPath)'))</_TestResultDirectory> | ||
| <_TestResultTrxFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsTrxPath)'))</_TestResultTrxFileName> | ||
| <_TestResultXmlFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsXmlPath)'))</_TestResultXmlFileName> | ||
| <_TestResultHtmlFileName>$([System.IO.Path]::GetFileName('%(TestToRun.ResultsHtmlPath)'))</_TestResultHtmlFileName> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <_TestEnvironment>%(TestToRun.EnvironmentDisplay)</_TestEnvironment> | ||
| <_TestAssembly>%(TestToRun.Identity)</_TestAssembly> | ||
| <_TestAssembly Condition="'$(OS)'=='Windows_NT'">$([System.IO.Path]::ChangeExtension($(_TestAssembly), '.exe'))</_TestAssembly> | ||
| <_TestAssembly Condition="'$(OS)'!='Windows_NT'">$(_TestAssembly.TrimEnd('.dll'))</_TestAssembly> | ||
| <_TestRuntime>%(TestToRun.TestRuntime)</_TestRuntime> | ||
| <_TestTimeout>%(TestToRun.TestTimeout)</_TestTimeout> | ||
radical marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <_TestRunnerAdditionalArguments>%(TestToRun.TestRunnerAdditionalArguments)</_TestRunnerAdditionalArguments> | ||
|
|
||
| <_TestRunner>$(_TestAssembly)</_TestRunner> | ||
| <_TestRunnerArgs>$(_TestRunnerAdditionalArguments) --results-directory "$(_TestResultDirectory)" --report-xunit --report-xunit-filename "$(_TestResultXmlFileName)" --report-xunit-html --report-xunit-html-filename "$(_TestResultHtmlFileName)" --report-trx --report-trx-filename "$(_TestResultTrxFileName)"</_TestRunnerArgs> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Condition="'$(_TestRuntime)' == 'Core'"> | ||
| <_TestRunnerArgs>$(_TestRunnerArgs) --auto-reporters off</_TestRunnerArgs> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <_TestRunnerCommand>"$(_TestRunner)" $(_TestRunnerArgs)</_TestRunnerCommand> | ||
|
|
||
| <!-- | ||
| Redirect std output of the runner. | ||
| Note that xUnit outputs failure info to both STDOUT (stack trace, message) and STDERR (failed test name) | ||
| --> | ||
| <_TestRunnerCommand Condition="'$(TestCaptureOutput)' != 'false'">$(_TestRunnerCommand) > "%(TestToRun.ResultsStdOutPath)" 2>&1</_TestRunnerCommand> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <_OutputFiles Include="%(TestToRun.ResultsXmlPath)" /> | ||
| <_OutputFiles Include="%(TestToRun.ResultsHtmlPath)" /> | ||
| <_OutputFiles Include="%(TestToRun.ResultsStdOutPath)" /> | ||
| </ItemGroup> | ||
|
|
||
| <MakeDir Directories="@(_OutputFiles->'%(RootDir)%(Directory)')"/> | ||
| <Delete Files="@(_OutputFiles)" /> | ||
|
|
||
| <Message Text="Running tests: $(_TestAssembly) [$(_TestEnvironment)]" Importance="high"/> | ||
| <Exec Command='$(_TestRunnerCommand)' | ||
| LogStandardErrorAsError="false" | ||
| WorkingDirectory="$(_TargetDir)" | ||
| IgnoreExitCode="true" | ||
| Timeout="$(_TestTimeout)" | ||
| EnvironmentVariables="DOTNET_ROOT=$(DotNetRoot);DOTNET_ROOT_X86=$(DotNetRoot)x86" | ||
| ContinueOnError="WarnAndContinue"> | ||
| <Output TaskParameter="ExitCode" PropertyName="_TestErrorCode" /> | ||
| </Exec> | ||
|
|
||
| <!-- | ||
| Add command line to the log. | ||
| --> | ||
| <WriteLinesToFile File="%(TestToRun.ResultsStdOutPath)" | ||
| Overwrite="false" | ||
| Lines=";=== COMMAND LINE ===;$(_TestRunnerCommand)" | ||
| Condition="'$(TestCaptureOutput)' != 'false'" /> | ||
|
|
||
| <!-- | ||
| Report test status. | ||
| --> | ||
| <Message Text="Tests succeeded: $(_TestAssembly) [$(_TestEnvironment)]" Condition="'$(_TestErrorCode)' == '0'" Importance="high" /> | ||
|
|
||
| <PropertyGroup> | ||
| <_ResultsFileToDisplay>%(TestToRun.ResultsHtmlPath)</_ResultsFileToDisplay> | ||
| <_ResultsFileToDisplay Condition="!Exists('$(_ResultsFileToDisplay)')">%(TestToRun.ResultsStdOutPath)</_ResultsFileToDisplay> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- | ||
| Ideally we would set ContinueOnError="ErrorAndContinue" so that when a test fails in multi-targeted test project | ||
| we'll still run tests for all target frameworks. ErrorAndContinue doesn't work well on Linux though: https://github.com/Microsoft/msbuild/issues/3961. | ||
| --> | ||
| <Error Text="Tests failed: $(_ResultsFileToDisplay) [$(_TestEnvironment)]" Condition="'$(_TestErrorCode)' != '0' and '$(_ErrorOnTestFailure)' != 'false'" File="XUnit" /> | ||
|
|
||
| <ItemGroup> | ||
| <FileWrites Include="@(_OutputFiles)"/> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| </Project> | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,10 @@ | |||||||||||||||||||
|
|
||||||||||||||||||||
| <PropertyGroup> | ||||||||||||||||||||
| <TargetFramework>$(DefaultTargetFramework)</TargetFramework> | ||||||||||||||||||||
| <!-- https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-exit-codes --> | ||||||||||||||||||||
| <!-- Exit code 8 is "zero tests ran" --> | ||||||||||||||||||||
| <!-- Currently, none of the tests in this project run in CI. All are ignored --> | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a real test project. It needs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @radical, no, this IS a test project. It contains tests. For example: aspire/tests/Aspire.Components.Common.Tests/ConformanceTests.cs Lines 106 to 109 in 8489a32
aspire/tests/Aspire.Components.Common.Tests/ConformanceTests.cs Lines 120 to 121 in 8489a32
All non-test infra was moved to Aspire.TestUtils. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But these tests are never run by themselves. They are run through other test classes that extend this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes here can be dropped, replaced by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In this case the project should be renamed to remove ".Tests" suffix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we do in a follow-up PR? |
||||||||||||||||||||
| <TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --ignore-exit-code 8</TestingPlatformCommandLineArguments> | ||||||||||||||||||||
danmoseley marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Youssef1313 this doesn't appear to be used in Microsoft.Testing.Platform.targets, which results in the tests to fail Should this be tucked on to aspire/eng/Xunit3/Microsoft.Testing.Platform.targets Lines 23 to 31 in fd413eb
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RussKie There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be the right way to fix this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can simply append There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, what I'm suggesting won't probably be possible without my PR on Arcade side. For now I think you could duplicate the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or simply just rename Aspire.Components.Common.Tests to end with TestUtilities if it's really not intended to be a test project, then you don't need the --ignore-exit-code 8 at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yep, working on it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we can do it easily (if at all). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RussKie You need to reference only |
||||||||||||||||||||
| </PropertyGroup> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <ItemGroup> | ||||||||||||||||||||
|
|
||||||||||||||||||||
This file was deleted.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this one still
dotnet test?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not intending to do any broader refactorings with this PR. This was
dotnet test, so I'm keeping as is. We can have a separate build step and then run the executable, but I'm trying to not change much as part of this PR.