Skip to content

Commit 128d887

Browse files
New test controller applied to Automation
1 parent 2f68db7 commit 128d887

29 files changed

+156
-306
lines changed

src/Automation/Automation.Test/ScenarioTests/AccountTests.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,33 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.Automation.Test;
16-
using Microsoft.Azure.ServiceManagement.Common.Models;
15+
using Microsoft.Azure.Commands.Network.Test.ScenarioTests;
1716
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1817
using Xunit;
1918

2019
namespace Commands.Automation.Test
2120
{
22-
public class AccountTests : AutomationScenarioTestsBase
21+
public class AccountTests : AutomationTestRunner
2322
{
24-
public XunitTracingInterceptor _logger;
25-
2623
public AccountTests(Xunit.Abstractions.ITestOutputHelper output)
24+
: base(output)
2725
{
28-
_logger = new XunitTracingInterceptor(output);
29-
XunitTracingInterceptor.AddToContext(_logger);
3026
}
3127

3228
[Fact]
3329
[Trait(Category.AcceptanceType, Category.CheckIn)]
3430
[Trait(Category.Service, Category.Automation)]
3531
public void TestGetAutomationAccts()
3632
{
37-
RunPowerShellTest(_logger, "Test-GetAutomationAccounts");
33+
TestRunner.RunTestScript("Test-GetAutomationAccounts");
3834
}
3935

4036
[Fact]
4137
[Trait(Category.AcceptanceType, Category.CheckIn)]
4238
[Trait(Category.Service, Category.Automation)]
4339
public void TestAutomationAcctTags()
4440
{
45-
RunPowerShellTest(_logger, "Test-AutomationAccountTags");
41+
TestRunner.RunTestScript("Test-AutomationAccountTags");
4642
}
4743
}
4844
}

src/Automation/Automation.Test/ScenarioTests/AutomationScenarioTestsBase.cs

Lines changed: 0 additions & 96 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Microsoft.Azure.Commands.TestFx;
7+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
8+
using Xunit.Abstractions;
9+
10+
namespace Microsoft.Azure.Commands.Network.Test.ScenarioTests
11+
{
12+
public class AutomationTestRunner
13+
{
14+
protected readonly ITestRunner TestRunner;
15+
16+
protected AutomationTestRunner(ITestOutputHelper output)
17+
{
18+
TestRunner = TestFx.TestManager.CreateInstance (output)
19+
.WithNewPsScriptFilename ($"{GetType().Name}.ps1")
20+
.WithProjectSubfolderForTests ("ScenarioTests")
21+
.WithCommonPsScripts (new[]
22+
{
23+
@"../AzureRM.Resources.ps1",
24+
})
25+
.WithNewRmModules (helper => new[]
26+
{
27+
helper.RMProfileModule,
28+
helper.GetRMModulePath(@"AzureRM.Automation.psd1")
29+
})
30+
.Build();
31+
}
32+
}
33+
}

src/Automation/Automation.Test/ScenarioTests/AutomationTests.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,76 +12,73 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.ServiceManagement.Common.Models;
15+
using Microsoft.Azure.Commands.Network.Test.ScenarioTests;
1616
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1717
using Xunit;
1818

1919
namespace Microsoft.Azure.Commands.Automation.Test
2020
{
21-
public class AutomationTests : AutomationScenarioTestsBase
21+
public class AutomationTests : AutomationTestRunner
2222
{
23-
public XunitTracingInterceptor _logger;
24-
2523
public AutomationTests(Xunit.Abstractions.ITestOutputHelper output)
24+
: base(output)
2625
{
27-
_logger = new XunitTracingInterceptor(output);
28-
XunitTracingInterceptor.AddToContext(_logger);
2926
}
3027

3128
[Fact(Skip = "Need x64 test framework.")]
3229
[Trait(Category.AcceptanceType, Category.CheckIn)]
3330
[Trait(Category.Service, Category.Automation)]
3431
public void TestAutomationStartAndStopRunbook()
3532
{
36-
RunPowerShellTest(_logger, "Test-AutomationStartAndStopRunbook -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1");
33+
TestRunner.RunTestScript("Test-AutomationStartAndStopRunbook -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1");
3734
}
3835

3936
[Fact(Skip = "Need x64 test framework.")]
4037
[Trait(Category.AcceptanceType, Category.CheckIn)]
4138
[Trait(Category.Service, Category.Automation)]
4239
public void TestAutomationPublishAndEditRunbook()
4340
{
44-
RunPowerShellTest(_logger, "Test-AutomationPublishAndEditRunbook -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1 -editRunbookPath Resources\\Automation\\Test-WorkflowV2.ps1");
41+
TestRunner.RunTestScript("Test-AutomationPublishAndEditRunbook -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1 -editRunbookPath Resources\\Automation\\Test-WorkflowV2.ps1");
4542
}
4643

4744
[Fact(Skip = "Need x64 test framework.")]
4845
[Trait(Category.AcceptanceType, Category.CheckIn)]
4946
[Trait(Category.Service, Category.Automation)]
5047
public void TestAutomationConfigureRunbook()
5148
{
52-
RunPowerShellTest(_logger, "Test-AutomationConfigureRunbook -runbookPath ScenarioTests\\Resources\\Write-DebugAndVerboseOutput.ps1");
49+
TestRunner.RunTestScript("Test-AutomationConfigureRunbook -runbookPath ScenarioTests\\Resources\\Write-DebugAndVerboseOutput.ps1");
5350
}
5451

5552
[Fact(Skip = "Need to re-record tests with latest version of automation library")]
5653
[Trait(Category.Service, Category.Automation)]
5754
[Trait(Category.RunType, Category.LiveOnly)]
5855
public void TestAutomationSuspendAndResumeJob()
5956
{
60-
RunPowerShellTest(_logger, "Test-AutomationSuspendAndResumeJob -runbookPath ScenarioTests\\Resources\\Use-WorkflowCheckpointSample.ps1");
57+
TestRunner.RunTestScript("Test-AutomationSuspendAndResumeJob -runbookPath ScenarioTests\\Resources\\Use-WorkflowCheckpointSample.ps1");
6158
}
6259

6360
[Fact(Skip = "Need to re-record tests with latest version of automation library")]
6461
[Trait(Category.Service, Category.Automation)]
6562
[Trait(Category.RunType, Category.LiveOnly)]
6663
public void TestAutomationStartRunbookOnASchedule()
6764
{
68-
RunPowerShellTest(_logger, "Test-AutomationStartRunbookOnASchedule -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1");
65+
TestRunner.RunTestScript("Test-AutomationStartRunbookOnASchedule -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1");
6966
}
7067

7168
[Fact(Skip = "Need x64 test framework.")]
7269
[Trait(Category.AcceptanceType, Category.CheckIn)]
7370
[Trait(Category.Service, Category.Automation)]
7471
public void TestAutomationStartUnpublishedRunbook()
7572
{
76-
RunPowerShellTest(_logger, "Test-AutomationStartUnpublishedRunbook -runbookPath ScenarioTests\\Resources\\Test-WorkFlowWithVariousParameters.ps1");
73+
TestRunner.RunTestScript("Test-AutomationStartUnpublishedRunbook -runbookPath ScenarioTests\\Resources\\Test-WorkFlowWithVariousParameters.ps1");
7774
}
7875

7976
[Fact(Skip = "Need x64 test framework.")]
8077
[Trait(Category.AcceptanceType, Category.CheckIn)]
8178
[Trait(Category.Service, Category.Automation)]
8279
public void TestAutomationRunbookWithParameter()
8380
{
84-
RunPowerShellTest(_logger, "Test-RunbookWithParameter -runbookPath ScenarioTests\\Resources\\fastJob.ps1 @{'nums'='[1,2,3,4,5,6,7]'} 28");
81+
TestRunner.RunTestScript("Test-RunbookWithParameter -runbookPath ScenarioTests\\Resources\\fastJob.ps1 @{'nums'='[1,2,3,4,5,6,7]'} 28");
8582
}
8683
}
8784
}

src/Automation/Automation.Test/ScenarioTests/CertificateTests.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,18 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
1516
namespace Commands.Automation.Test
1617
{
17-
using System;
18-
using System.Collections.Generic;
19-
using System.Linq;
20-
using System.Text;
21-
using System.Threading.Tasks;
22-
using Microsoft.Azure.Commands.Automation.Test;
23-
using Microsoft.Azure.ServiceManagement.Common.Models;
18+
using Microsoft.Azure.Commands.Network.Test.ScenarioTests;
2419
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2520
using Xunit;
26-
public class CertificateTests : AutomationScenarioTestsBase
27-
{
28-
public XunitTracingInterceptor logger;
2921

22+
public class CertificateTests : AutomationTestRunner
23+
{
3024
public CertificateTests(Xunit.Abstractions.ITestOutputHelper output)
25+
: base(output)
3126
{
32-
logger = new XunitTracingInterceptor(output);
33-
XunitTracingInterceptor.AddToContext(logger);
3427
}
3528

3629
[Fact]
@@ -40,7 +33,7 @@ public CertificateTests(Xunit.Abstractions.ITestOutputHelper output)
4033
[Trait(Category.AcceptanceType, Category.BVT)]
4134
public void TestE2ECertificates()
4235
{
43-
RunPowerShellTest(logger, "Test-E2ECertificates");
36+
TestRunner.RunTestScript("Test-E2ECertificates");
4437
}
4538

4639
}

src/Automation/Automation.Test/ScenarioTests/ConnectionTests.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,18 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
1516
namespace Commands.Automation.Test
1617
{
17-
using System;
18-
using System.Collections.Generic;
19-
using System.Linq;
20-
using System.Text;
21-
using System.Threading.Tasks;
22-
using Microsoft.Azure.Commands.Automation.Test;
23-
using Microsoft.Azure.ServiceManagement.Common.Models;
18+
using Microsoft.Azure.Commands.Network.Test.ScenarioTests;
2419
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2520
using Xunit;
26-
public class ConnectionTests : AutomationScenarioTestsBase
27-
{
28-
public XunitTracingInterceptor logger;
2921

22+
public class ConnectionTests : AutomationTestRunner
23+
{
3024
public ConnectionTests(Xunit.Abstractions.ITestOutputHelper output)
25+
: base(output)
3126
{
32-
logger = new XunitTracingInterceptor(output);
33-
XunitTracingInterceptor.AddToContext(logger);
3427
}
3528

3629
[Fact]
@@ -40,7 +33,7 @@ public ConnectionTests(Xunit.Abstractions.ITestOutputHelper output)
4033
[Trait(Category.AcceptanceType, Category.BVT)]
4134
public void TestE2EConnections()
4235
{
43-
RunPowerShellTest(logger, "Test-E2EConnections");
36+
TestRunner.RunTestScript("Test-E2EConnections");
4437
}
4538
}
4639
}

src/Automation/Automation.Test/ScenarioTests/CredentialTests.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,19 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Network.Test.ScenarioTests;
16+
1517
namespace Commands.Automation.Test
1618
{
17-
using System;
18-
using System.Collections.Generic;
19-
using System.Linq;
20-
using System.Text;
21-
using System.Threading.Tasks;
22-
using Microsoft.Azure.Commands.Automation.Test;
2319
using Microsoft.Azure.ServiceManagement.Common.Models;
2420
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2521
using Xunit;
2622

27-
public class CredentialTests : AutomationScenarioTestsBase
23+
public class CredentialTests : AutomationTestRunner
2824
{
29-
public XunitTracingInterceptor logger;
30-
3125
public CredentialTests(Xunit.Abstractions.ITestOutputHelper output)
26+
: base(output)
3227
{
33-
logger = new XunitTracingInterceptor(output);
34-
XunitTracingInterceptor.AddToContext(logger);
3528
}
3629

3730
[Fact]
@@ -41,7 +34,7 @@ public CredentialTests(Xunit.Abstractions.ITestOutputHelper output)
4134
[Trait(Category.AcceptanceType, Category.BVT)]
4235
public void TestE2ECRedentials()
4336
{
44-
RunPowerShellTest(logger, "Test-E2ECredentials");
37+
TestRunner.RunTestScript("Test-E2ECredentials");
4538
}
4639
}
4740
}

0 commit comments

Comments
 (0)