Skip to content

Commit

Permalink
Add TestRunner and replace TestBase (#18399)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainFanZzz committed Jun 6, 2022
1 parent ec4bc31 commit 13e3a8f
Show file tree
Hide file tree
Showing 18 changed files with 210 additions and 362 deletions.

This file was deleted.

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.DataFactories.Test.ScenarioTests
{
public class DataFactoriesTestRunner
{
protected readonly ITestRunner TestRunner;

protected DataFactoriesTestRunner(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.DataFactory.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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,23 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

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

namespace Microsoft.Azure.Commands.DataFactories.Test
{
public class DataFactoryGatewayTests : DataFactoriesScenarioTestsBase
public class DataFactoryGatewayTests : DataFactoriesTestRunner
{
public XunitTracingInterceptor _logger;

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

[Fact(Skip = "test takes too long (more than 5 sec)")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetNonExistingDataFactoryGateway()
{
RunPowerShellTest(_logger, "Test-GetNonExistingDataFactoryGateway");
TestRunner.RunTestScript("Test-GetNonExistingDataFactoryGateway");
}

#if NETSTANDARD
Expand All @@ -44,7 +40,7 @@ public void TestGetNonExistingDataFactoryGateway()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateDataFactoryGateway()
{
RunPowerShellTest(_logger, "Test-DataFactoryGateway");
TestRunner.RunTestScript("Test-DataFactoryGateway");
}

#if NETSTANDARD
Expand All @@ -56,14 +52,14 @@ public void TestCreateDataFactoryGateway()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDataFactoryGatewayAuthKey()
{
RunPowerShellTest(_logger, "Test-DataFactoryGatewayAuthKey");
TestRunner.RunTestScript("Test-DataFactoryGatewayAuthKey");
}

[Fact(Skip = "test takes too long (more than 5 sec)")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateDataFactoryGatewayWithDataFactoryParameter()
{
RunPowerShellTest(_logger, "Test-DataFactoryGatewayWithDataFactoryParameter");
TestRunner.RunTestScript("Test-DataFactoryGatewayWithDataFactoryParameter");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,16 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

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

namespace Microsoft.Azure.Commands.DataFactories.Test
{
public class DataFactoryTests : DataFactoriesScenarioTestsBase
public class DataFactoryTests : DataFactoriesTestRunner
{
public XunitTracingInterceptor _logger;

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

#if NETSTANDARD
Expand All @@ -37,7 +33,7 @@ public DataFactoryTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetNonExistingDataFactory()
{
RunPowerShellTest(_logger, "Test-GetNonExistingDataFactory");
TestRunner.RunTestScript("Test-GetNonExistingDataFactory");
}

#if NETSTANDARD
Expand All @@ -49,7 +45,7 @@ public void TestGetNonExistingDataFactory()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateDataFactory()
{
RunPowerShellTest(_logger, "Test-CreateDataFactory");
TestRunner.RunTestScript("Test-CreateDataFactory");
}

#if NETSTANDARD
Expand All @@ -61,7 +57,7 @@ public void TestCreateDataFactory()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDeleteDataFactoryWithDataFactoryParameter()
{
RunPowerShellTest(_logger, "Test-DeleteDataFactoryWithDataFactoryParameter");
TestRunner.RunTestScript("Test-DeleteDataFactoryWithDataFactoryParameter");
}

#if NETSTANDARD
Expand All @@ -73,7 +69,7 @@ public void TestDeleteDataFactoryWithDataFactoryParameter()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDataFactoryPiping()
{
RunPowerShellTest(_logger, "Test-DataFactoryPiping");
TestRunner.RunTestScript("Test-DataFactoryPiping");
}
}
}
16 changes: 6 additions & 10 deletions src/DataFactory/DataFactories.Test/ScenarioTests/HubTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,16 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

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

namespace Microsoft.Azure.Commands.DataFactories.Test
{
public class HubTests : DataFactoriesScenarioTestsBase
public class HubTests : DataFactoriesTestRunner
{
public XunitTracingInterceptor _logger;

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

#if NETSTANDARD
Expand All @@ -37,7 +33,7 @@ public HubTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestHub()
{
RunPowerShellTest(_logger, "Test-Hub");
TestRunner.RunTestScript("Test-Hub");
}

#if NETSTANDARD
Expand All @@ -49,7 +45,7 @@ public void TestHub()
#endif
public void TestHubWithDataFactoryParameter()
{
RunPowerShellTest(_logger, "Test-HubWithDataFactoryParameter");
TestRunner.RunTestScript("Test-HubWithDataFactoryParameter");
}

#if NETSTANDARD
Expand All @@ -61,7 +57,7 @@ public void TestHubWithDataFactoryParameter()
#endif
public void TestHubPiping()
{
RunPowerShellTest(_logger, "Test-HubPiping");
TestRunner.RunTestScript("Test-HubPiping");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,16 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

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

namespace Microsoft.Azure.Commands.DataFactories.Test
{
public class LinkedServiceTests : DataFactoriesScenarioTestsBase
public class LinkedServiceTests : DataFactoriesTestRunner
{
public XunitTracingInterceptor _logger;

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

#if NETSTANDARD
Expand All @@ -37,7 +33,7 @@ public LinkedServiceTests(Xunit.Abstractions.ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLinkedService()
{
RunPowerShellTest(_logger, "Test-LinkedService");
TestRunner.RunTestScript("Test-LinkedService");
}

#if NETSTANDARD
Expand All @@ -49,7 +45,7 @@ public void TestLinkedService()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLinkedServiceWithDataFactoryParameter()
{
RunPowerShellTest(_logger, "Test-LinkedServiceWithDataFactoryParameter");
TestRunner.RunTestScript("Test-LinkedServiceWithDataFactoryParameter");
}

#if NETSTANDARD
Expand All @@ -61,7 +57,7 @@ public void TestLinkedServiceWithDataFactoryParameter()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLinkedServicePiping()
{
RunPowerShellTest(_logger, "Test-LinkedServicePiping");
TestRunner.RunTestScript("Test-LinkedServicePiping");
}
}
}
Loading

0 comments on commit 13e3a8f

Please sign in to comment.