11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33
4+ using Microsoft . Build . Logging . StructuredLogger ;
45using Microsoft . Testing . Platform . Acceptance . IntegrationTests . Helpers ;
56
7+ using SL = Microsoft . Build . Logging . StructuredLogger ;
8+ using SystemTask = System . Threading . Tasks . Task ;
9+
610namespace Microsoft . Testing . Platform . Acceptance . IntegrationTests ;
711
812[ TestGroup ]
@@ -19,7 +23,7 @@ public MSTestRunnerTests(ITestExecutionContext testExecutionContext, AcceptanceF
1923 }
2024
2125 [ ArgumentsProvider ( nameof ( GetBuildMatrixTfmBuildVerbConfiguration ) ) ]
22- public async Task EnableMSTestRunner_True_Will_Run_Standalone ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
26+ public async SystemTask EnableMSTestRunner_True_Will_Run_Standalone ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
2327 {
2428 await Lock . WaitAsync ( ) ;
2529 try
@@ -39,6 +43,12 @@ public async Task EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildC
3943 compilationResult = await DotnetCli . RunAsync (
4044 $ "{ verb } -m:1 -nodeReuse:false { generator . TargetAssetPath } -c { buildConfiguration } -bl:{ binlogFile } -r { RID } ",
4145 _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
46+
47+ SL . Build binLog = SL . Serialization . Read ( binlogFile ) ;
48+ Assert . IsNotEmpty ( binLog . FindChildrenRecursive < AddItem > ( )
49+ . Where ( x => x . Title . Contains ( "ProjectCapability" ) )
50+ . Where ( x => x . Children . Any ( c => ( ( Item ) c ) . Name == "TestingPlatformServer" ) ) ) ;
51+
4252 var testHost = TestInfrastructure . TestHost . LocateFrom ( generator . TargetAssetPath , AssetName , tfm , buildConfiguration : buildConfiguration , verb : verb ) ;
4353 var testHostResult = await testHost . ExecuteAsync ( ) ;
4454 testHostResult . AssertOutputContains ( "Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1" ) ;
@@ -50,7 +60,7 @@ public async Task EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildC
5060 }
5161
5262 [ ArgumentsProvider ( nameof ( GetBuildMatrixTfmBuildVerbConfiguration ) ) ]
53- public async Task EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalone ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
63+ public async SystemTask EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalone ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
5464 {
5565 await Lock . WaitAsync ( ) ;
5666 try
@@ -94,21 +104,21 @@ public async Task EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalo
94104 }
95105
96106 [ ArgumentsProvider ( nameof ( GetBuildMatrixTfmBuildVerbConfiguration ) ) ]
97- public async Task EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_From_Tpv2_SDK ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
107+ public async SystemTask EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_From_Tpv2_SDK ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
98108 {
99109 await Lock . WaitAsync ( ) ;
100110 try
101111 {
102112 using TestAsset generator = await TestAsset . GenerateAssetAsync (
103- AssetName ,
104- CurrentMSTestSourceCode
105- . PatchCodeWithReplace ( "$TargetFramework$" , $ "<TargetFramework>{ tfm } </TargetFramework>")
106- . PatchCodeWithReplace ( "$MicrosoftNETTestSdkVersion$" , MicrosoftNETTestSdkVersion )
107- . PatchCodeWithReplace ( "$MSTestVersion$" , MSTestVersion )
108- . PatchCodeWithReplace ( "$EnableMSTestRunner$" , "<EnableMSTestRunner>false</EnableMSTestRunner>" )
109- . PatchCodeWithReplace ( "$OutputType$" , "<OutputType>Exe</OutputType>" )
110- . PatchCodeWithReplace ( "$Extra$" , string . Empty ) ,
111- addPublicFeeds : true ) ;
113+ AssetName ,
114+ CurrentMSTestSourceCode
115+ . PatchCodeWithReplace ( "$TargetFramework$" , $ "<TargetFramework>{ tfm } </TargetFramework>")
116+ . PatchCodeWithReplace ( "$MicrosoftNETTestSdkVersion$" , MicrosoftNETTestSdkVersion )
117+ . PatchCodeWithReplace ( "$MSTestVersion$" , MSTestVersion )
118+ . PatchCodeWithReplace ( "$EnableMSTestRunner$" , "<EnableMSTestRunner>false</EnableMSTestRunner>" )
119+ . PatchCodeWithReplace ( "$OutputType$" , "<OutputType>Exe</OutputType>" )
120+ . PatchCodeWithReplace ( "$Extra$" , string . Empty ) ,
121+ addPublicFeeds : true ) ;
112122 string binlogFile = Path . Combine ( generator . TargetAssetPath , "msbuild.binlog" ) ;
113123 var compilationResult = await DotnetCli . RunAsync ( $ "restore -m:1 -nodeReuse:false { generator . TargetAssetPath } -r { RID } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
114124 try
@@ -134,4 +144,36 @@ public async Task EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_Fro
134144 Lock . Release ( ) ;
135145 }
136146 }
147+
148+ [ ArgumentsProvider ( nameof ( GetBuildMatrixTfmBuildVerbConfiguration ) ) ]
149+ public async SystemTask EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
150+ {
151+ await Lock . WaitAsync ( ) ;
152+ try
153+ {
154+ using TestAsset generator = await TestAsset . GenerateAssetAsync (
155+ AssetName ,
156+ CurrentMSTestSourceCode
157+ . PatchCodeWithReplace ( "$TargetFramework$" , $ "<TargetFramework>{ tfm } </TargetFramework>")
158+ . PatchCodeWithReplace ( "$MicrosoftNETTestSdkVersion$" , MicrosoftNETTestSdkVersion )
159+ . PatchCodeWithReplace ( "$MSTestVersion$" , MSTestVersion )
160+ . PatchCodeWithReplace ( "$EnableMSTestRunner$" , string . Empty )
161+ . PatchCodeWithReplace ( "$OutputType$" , string . Empty )
162+ . PatchCodeWithReplace ( "$Extra$" , string . Empty ) ,
163+ addPublicFeeds : false ) ;
164+
165+ string binlogFile = Path . Combine ( generator . TargetAssetPath , "msbuild.binlog" ) ;
166+ var compilationResult = await DotnetCli . RunAsync ( $ "restore -m:1 -nodeReuse:false { generator . TargetAssetPath } -r { RID } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
167+ compilationResult = await DotnetCli . RunAsync ( $ "{ verb } -bl:{ binlogFile } -m:1 -nodeReuse:false { generator . TargetAssetPath } -c { buildConfiguration } -r { RID } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
168+
169+ SL . Build binLog = SL . Serialization . Read ( binlogFile ) ;
170+ Assert . IsEmpty ( binLog . FindChildrenRecursive < AddItem > ( )
171+ . Where ( x => x . Title . Contains ( "ProjectCapability" ) )
172+ . Where ( x => x . Children . Any ( c => ( ( Item ) c ) . Name == "TestingPlatformServer" ) ) ) ;
173+ }
174+ finally
175+ {
176+ Lock . Release ( ) ;
177+ }
178+ }
137179}
0 commit comments