Skip to content

Commit 8c9a73f

Browse files
v-yuzhichenZiyue Zheng
andauthored
Add DevSpacesTestRunner to replace TestController (#18109)
* Add DevSpacesTestRunner to replace TestController * Add DevSpacesTestRunner to replace TestController * Add DevSpacesTestRunner to replace TestController Co-authored-by: Ziyue Zheng <[email protected]>
1 parent baeb930 commit 8c9a73f

File tree

3 files changed

+73
-108
lines changed

3 files changed

+73
-108
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Collections.Generic;
16+
using Microsoft.Azure.Commands.TestFx;
17+
using Xunit.Abstractions;
18+
19+
namespace Microsoft.Azure.Commands.DevSpaces.Test.ScenarioTests
20+
{
21+
public class DevSpacesTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected DevSpacesTestRunner(ITestOutputHelper output)
26+
{
27+
TestRunner = TestManager.CreateInstance(output)
28+
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
29+
.WithProjectSubfolderForTests("ScenarioTests")
30+
.WithCommonPsScripts(new[]
31+
{
32+
@"Common.ps1",
33+
})
34+
.WithNewRmModules(helper => new[]
35+
{
36+
helper.RMProfileModule,
37+
helper.RMResourceModule,
38+
helper.GetRMModulePath(@"Az.DevSpaces.psd1")
39+
})
40+
.WithNewRecordMatcherArguments(
41+
userAgentsToIgnore: new Dictionary<string, string>
42+
{
43+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
44+
},
45+
resourceProviders: new Dictionary<string, string>
46+
{
47+
{"Microsoft.Resources", null},
48+
{"Microsoft.Features", null},
49+
{"Microsoft.Authorization", null}
50+
}
51+
)
52+
.Build();
53+
}
54+
}
55+
}
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
1-
using Microsoft.Azure.Commands.ScenarioTest;
2-
using Microsoft.Azure.ServiceManagement.Common.Models;
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
315
using Microsoft.WindowsAzure.Commands.ScenarioTest;
4-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
516
using Xunit;
6-
using Xunit.Abstractions;
717

818
namespace Microsoft.Azure.Commands.DevSpaces.Test.ScenarioTests
919
{
10-
public class DevSpacesTests : RMTestBase
20+
public class DevSpacesTests : DevSpacesTestRunner
1121
{
12-
public XunitTracingInterceptor _logger;
13-
14-
public DevSpacesTests(Xunit.Abstractions.ITestOutputHelper output)
22+
public DevSpacesTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
1523
{
16-
_logger = new XunitTracingInterceptor(output);
17-
XunitTracingInterceptor.AddToContext(_logger);
18-
TestExecutionHelpers.SetUpSessionAndProfile();
1924
}
2025

2126
[Fact]
2227
[Trait(Category.AcceptanceType, Category.CheckIn)]
2328
public void TestAzureDevSpaces()
2429
{
25-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AzureRmDevSpacesController");
30+
TestRunner.RunTestScript("Test-AzureRmDevSpacesController");
2631
}
2732

2833
[Fact]
2934
[Trait(Category.AcceptanceType, Category.CheckIn)]
3035
public void TestAzureDevSpacesAsJobParameter()
3136
{
32-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-TestAzureDevSpacesAsJobParameter");
37+
TestRunner.RunTestScript("Test-TestAzureDevSpacesAsJobParameter");
3338
}
3439
}
3540
}

src/DevSpaces/DevSpaces.Test/ScenarioTests/TestController.cs

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)