Skip to content

Commit

Permalink
Add SupportTestRunner to replace TestController (Azure#18188)
Browse files Browse the repository at this point in the history
* Add SupportTestRunner to replace TestController

* Revert Az.Support document changes
  • Loading branch information
ziyuezh576 authored May 19, 2022
1 parent a19de70 commit de81122
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 181 deletions.
23 changes: 8 additions & 15 deletions src/Support/Support.Test/ScenarioTests/CommunicationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,64 +12,57 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.Support.Test.ScenarioTests
{
public class CommunicationTests
public class CommunicationTests : SupportTestRunner
{
private XunitTracingInterceptor _logger;

public CommunicationTests(Xunit.Abstractions.ITestOutputHelper output)
public CommunicationTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void NewAzSupportTicketCommunicationNameParameterSet()
{
TestController.NewInstance.RunPowerShellTest(_logger, "New-AzSupportTicketCommunicationNameParameterSet");
TestRunner.RunTestScript("New-AzSupportTicketCommunicationNameParameterSet");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void NewAzSupportTicketCommunicationParentObjectParameterSet()
{
TestController.NewInstance.RunPowerShellTest(_logger, "New-AzSupportTicketCommunicationParentObjectParameterSet");
TestRunner.RunTestScript("New-AzSupportTicketCommunicationParentObjectParameterSet");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportTicketCommunicationByNameParameterSet()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportTicketCommunicationByNameParameterSet");
TestRunner.RunTestScript("Get-AzSupportTicketCommunicationByNameParameterSet");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportTicketCommunicationFilterByCommunicationType()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportTicketCommunicationFilterByCommunicationType");
TestRunner.RunTestScript("Get-AzSupportTicketCommunicationFilterByCommunicationType");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportTicketCommunicationPagingParameters()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportTicketCommunicationPagingParameters");
TestRunner.RunTestScript("Get-AzSupportTicketCommunicationPagingParameters");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportTicketCommunicationByParentObjectParameterSet()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportTicketCommunicationByParentObjectParameterSet");
TestRunner.RunTestScript("Get-AzSupportTicketCommunicationByParentObjectParameterSet");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,64 +12,57 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.Support.Test.ScenarioTests
{
public class ProblemClassificationTests
public class ProblemClassificationTests : SupportTestRunner
{
private XunitTracingInterceptor _logger;

public ProblemClassificationTests(Xunit.Abstractions.ITestOutputHelper output)
public ProblemClassificationTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportProblemClassificationServiceName()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportProblemClassificationServiceName");
TestRunner.RunTestScript("Get-AzSupportProblemClassificationServiceName");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportProblemClassificationAllParametersNameAlias()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportProblemClassificationAllParametersNameAlias");
TestRunner.RunTestScript("Get-AzSupportProblemClassificationAllParametersNameAlias");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportProblemClassificationAllParametersId()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportProblemClassificationAllParametersId");
TestRunner.RunTestScript("Get-AzSupportProblemClassificationAllParametersId");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportProblemClassificationAllParametersResourceId()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportProblemClassificationAllParametersResourceId");
TestRunner.RunTestScript("Get-AzSupportProblemClassificationAllParametersResourceId");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportProblemClassificationParentObjectServiceName()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportProblemClassificationParentObjectServiceName");
TestRunner.RunTestScript("Get-AzSupportProblemClassificationParentObjectServiceName");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportProblemClassificationParentObjectAllParameters()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportProblemClassificationParentObjectAllParameters");
TestRunner.RunTestScript("Get-AzSupportProblemClassificationParentObjectAllParameters");
}
}
}
19 changes: 6 additions & 13 deletions src/Support/Support.Test/ScenarioTests/ServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,43 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.Support.Test.ScenarioTests
{
public class ServiceTests
public class ServiceTests : SupportTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public ServiceTests(Xunit.Abstractions.ITestOutputHelper output)
public ServiceTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportServiceNoParameter()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportServiceNoParameter");
TestRunner.RunTestScript("Get-AzSupportServiceNoParameter");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportServiceByNameParameterSetUsingNameAlias()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportServiceByNameParameterSetUsingNameAlias");
TestRunner.RunTestScript("Get-AzSupportServiceByNameParameterSetUsingNameAlias");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportServiceByNameParameterSetUsingId()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportServiceByNameParameterSetUsingId");
TestRunner.RunTestScript("Get-AzSupportServiceByNameParameterSetUsingId");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetAzSupportServiceByNameParameterSetUsingCompleteResourceId()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Get-AzSupportServiceByNameParameterSetUsingCompleteResourceId");
TestRunner.RunTestScript("Get-AzSupportServiceByNameParameterSetUsingCompleteResourceId");
}
}
}
55 changes: 55 additions & 0 deletions src/Support/Support.Test/ScenarioTests/SupportTestRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Collections.Generic;
using Microsoft.Azure.Commands.TestFx;
using Xunit.Abstractions;

namespace Microsoft.Azure.Commands.Support.Test.ScenarioTests
{
public class SupportTestRunner
{
protected readonly ITestRunner TestRunner;

protected SupportTestRunner(ITestOutputHelper output)
{
TestRunner = TestManager.CreateInstance(output)
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
.WithProjectSubfolderForTests("ScenarioTests")
.WithCommonPsScripts(new[]
{
@"Common.ps1",
@"../AzureRM.Resources.ps1"
})
.WithNewRmModules(helper => new[]
{
helper.RMProfileModule,
helper.GetRMModulePath("Az.Support.psd1")
})
.WithNewRecordMatcherArguments(
userAgentsToIgnore: new Dictionary<string, string>
{
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
},
resourceProviders: new Dictionary<string, string>
{
{"Microsoft.Resources", null},
{"Microsoft.Features", null},
{"Microsoft.Authorization", null}
}
)
.Build();
}
}
}
Loading

0 comments on commit de81122

Please sign in to comment.