Skip to content

Commit b95b60b

Browse files
authored
Merge pull request #8285 from vladimir-shcherbakov/tc-core-automation
[Test Controller] New test controller applied to Automation
2 parents 2438f21 + 72be768 commit b95b60b

29 files changed

+159
-345
lines changed

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

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

15-
using Microsoft.Azure.Commands.Automation.Test;
16-
using Microsoft.Azure.ServiceManagement.Common.Models;
1715
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1816
using Xunit;
1917

2018
namespace Commands.Automation.Test
2119
{
22-
public class AccountTests : AutomationScenarioTestsBase
20+
public class AccountTests : AutomationTestRunner
2321
{
24-
public XunitTracingInterceptor _logger;
25-
2622
public AccountTests(Xunit.Abstractions.ITestOutputHelper output)
23+
: base(output)
2724
{
28-
_logger = new XunitTracingInterceptor(output);
29-
XunitTracingInterceptor.AddToContext(_logger);
3025
}
3126

3227
[Fact]
3328
[Trait(Category.AcceptanceType, Category.CheckIn)]
3429
[Trait(Category.Service, Category.Automation)]
3530
public void TestGetAutomationAccts()
3631
{
37-
RunPowerShellTest(_logger, "Test-GetAutomationAccounts");
32+
TestRunner.RunTestScript("Test-GetAutomationAccounts");
3833
}
3934

4035
[Fact]
4136
[Trait(Category.AcceptanceType, Category.CheckIn)]
4237
[Trait(Category.Service, Category.Automation)]
4338
public void TestAutomationAcctTags()
4439
{
45-
RunPowerShellTest(_logger, "Test-AutomationAccountTags");
40+
TestRunner.RunTestScript("Test-AutomationAccountTags");
4641
}
4742
}
4843
}

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

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

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,84 +12,80 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.ServiceManagement.Common.Models;
1615
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1716
using Xunit;
1817

19-
namespace Microsoft.Azure.Commands.Automation.Test
18+
namespace Commands.Automation.Test
2019
{
21-
public class AutomationTests : AutomationScenarioTestsBase
20+
public class AutomationTests : AutomationTestRunner
2221
{
23-
public XunitTracingInterceptor _logger;
24-
2522
public AutomationTests(Xunit.Abstractions.ITestOutputHelper output)
23+
: base(output)
2624
{
27-
_logger = new XunitTracingInterceptor(output);
28-
XunitTracingInterceptor.AddToContext(_logger);
2925
}
3026

3127
[Fact(Skip = "Need x64 test framework.")]
3228
[Trait(Category.AcceptanceType, Category.CheckIn)]
3329
[Trait(Category.Service, Category.Automation)]
3430
public void TestAutomationStartAndStopRunbook()
3531
{
36-
RunPowerShellTest(_logger, "Test-AutomationStartAndStopRunbook -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1");
32+
TestRunner.RunTestScript("Test-AutomationStartAndStopRunbook -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1");
3733
}
3834

3935
[Fact(Skip = "Need x64 test framework.")]
4036
[Trait(Category.AcceptanceType, Category.CheckIn)]
4137
[Trait(Category.Service, Category.Automation)]
4238
public void TestAutomationPublishAndEditRunbook()
4339
{
44-
RunPowerShellTest(_logger, "Test-AutomationPublishAndEditRunbook -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1 -editRunbookPath Resources\\Automation\\Test-WorkflowV2.ps1");
40+
TestRunner.RunTestScript("Test-AutomationPublishAndEditRunbook -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1 -editRunbookPath Resources\\Automation\\Test-WorkflowV2.ps1");
4541
}
4642

4743
[Fact(Skip = "Need x64 test framework.")]
4844
[Trait(Category.AcceptanceType, Category.CheckIn)]
4945
[Trait(Category.Service, Category.Automation)]
5046
public void TestAutomationConfigureRunbook()
5147
{
52-
RunPowerShellTest(_logger, "Test-AutomationConfigureRunbook -runbookPath ScenarioTests\\Resources\\Write-DebugAndVerboseOutput.ps1");
48+
TestRunner.RunTestScript("Test-AutomationConfigureRunbook -runbookPath ScenarioTests\\Resources\\Write-DebugAndVerboseOutput.ps1");
5349
}
5450

5551
[Fact(Skip = "Need to re-record tests with latest version of automation library")]
5652
[Trait(Category.Service, Category.Automation)]
5753
[Trait(Category.RunType, Category.LiveOnly)]
5854
public void TestAutomationSuspendAndResumeJob()
5955
{
60-
RunPowerShellTest(_logger, "Test-AutomationSuspendAndResumeJob -runbookPath ScenarioTests\\Resources\\Use-WorkflowCheckpointSample.ps1");
56+
TestRunner.RunTestScript("Test-AutomationSuspendAndResumeJob -runbookPath ScenarioTests\\Resources\\Use-WorkflowCheckpointSample.ps1");
6157
}
6258

6359
[Fact(Skip = "Need to re-record tests with latest version of automation library")]
6460
[Trait(Category.Service, Category.Automation)]
6561
[Trait(Category.RunType, Category.LiveOnly)]
6662
public void TestAutomationStartRunbookOnASchedule()
6763
{
68-
RunPowerShellTest(_logger, "Test-AutomationStartRunbookOnASchedule -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1");
64+
TestRunner.RunTestScript("Test-AutomationStartRunbookOnASchedule -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1");
6965
}
7066

7167
[Fact(Skip = "Need x64 test framework.")]
7268
[Trait(Category.AcceptanceType, Category.CheckIn)]
7369
[Trait(Category.Service, Category.Automation)]
7470
public void TestAutomationStartUnpublishedRunbook()
7571
{
76-
RunPowerShellTest(_logger, "Test-AutomationStartUnpublishedRunbook -runbookPath ScenarioTests\\Resources\\Test-WorkFlowWithVariousParameters.ps1");
72+
TestRunner.RunTestScript("Test-AutomationStartUnpublishedRunbook -runbookPath ScenarioTests\\Resources\\Test-WorkFlowWithVariousParameters.ps1");
7773
}
7874

7975
[Fact(Skip = "Need x64 test framework.")]
8076
[Trait(Category.AcceptanceType, Category.CheckIn)]
8177
[Trait(Category.Service, Category.Automation)]
8278
public void TestAutomationRunbookWithParameter()
8379
{
84-
RunPowerShellTest(_logger, "Test-RunbookWithParameter -runbookPath ScenarioTests\\Resources\\fastJob.ps1 -type 'PowerShell' -parameters @{'nums'='[1,2,3,4,5,6,7]'} -expectedResult 28");
80+
TestRunner.RunTestScript("Test-RunbookWithParameter -runbookPath ScenarioTests\\Resources\\fastJob.ps1 -type 'PowerShell' -parameters @{'nums'='[1,2,3,4,5,6,7]'} -expectedResult 28");
8581
}
8682

8783
[Fact(Skip = "Need x64 test framework.")]
8884
[Trait(Category.AcceptanceType, Category.CheckIn)]
8985
[Trait(Category.Service, Category.Automation)]
9086
public void TestAutomationPy2RunbookWithParameter()
9187
{
92-
RunPowerShellTest(_logger, "Test-RunbookWithParameter -runbookPath ScenarioTests\\Resources\\fastJob.py -type 'Python2' -parameters @{'param1'='1';'param2'='2';'param3'='3';'param4'='4';'param5'='5';'param6'='6';'param7'='7'} -expectedResult 28");
88+
TestRunner.RunTestScript("Test-RunbookWithParameter -runbookPath ScenarioTests\\Resources\\fastJob.py -type 'Python2' -parameters @{'param1'='1';'param2'='2';'param3'='3';'param4'='4';'param5'='5';'param6'='6';'param7'='7'} -expectedResult 28");
9389
}
9490
}
9591
}

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

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

15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
1518
namespace Commands.Automation.Test
1619
{
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;
24-
using Microsoft.WindowsAzure.Commands.ScenarioTest;
25-
using Xunit;
26-
public class CertificateTests : AutomationScenarioTestsBase
20+
public class CertificateTests : AutomationTestRunner
2721
{
28-
public XunitTracingInterceptor logger;
29-
3022
public CertificateTests(Xunit.Abstractions.ITestOutputHelper output)
23+
: base(output)
3124
{
32-
logger = new XunitTracingInterceptor(output);
33-
XunitTracingInterceptor.AddToContext(logger);
3425
}
3526

3627
[Fact]
@@ -40,7 +31,7 @@ public CertificateTests(Xunit.Abstractions.ITestOutputHelper output)
4031
[Trait(Category.AcceptanceType, Category.BVT)]
4132
public void TestE2ECertificates()
4233
{
43-
RunPowerShellTest(logger, "Test-E2ECertificates");
34+
TestRunner.RunTestScript("Test-E2ECertificates");
4435
}
4536

4637
}

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

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

15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
1518
namespace Commands.Automation.Test
1619
{
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;
24-
using Microsoft.WindowsAzure.Commands.ScenarioTest;
25-
using Xunit;
26-
public class ConnectionTests : AutomationScenarioTestsBase
20+
public class ConnectionTests : AutomationTestRunner
2721
{
28-
public XunitTracingInterceptor logger;
29-
3022
public ConnectionTests(Xunit.Abstractions.ITestOutputHelper output)
23+
: base(output)
3124
{
32-
logger = new XunitTracingInterceptor(output);
33-
XunitTracingInterceptor.AddToContext(logger);
3425
}
3526

3627
[Fact]
@@ -40,7 +31,7 @@ public ConnectionTests(Xunit.Abstractions.ITestOutputHelper output)
4031
[Trait(Category.AcceptanceType, Category.BVT)]
4132
public void TestE2EConnections()
4233
{
43-
RunPowerShellTest(logger, "Test-E2EConnections");
34+
TestRunner.RunTestScript("Test-E2EConnections");
4435
}
4536
}
4637
}

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

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

15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
1518
namespace Commands.Automation.Test
1619
{
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;
24-
using Microsoft.WindowsAzure.Commands.ScenarioTest;
25-
using Xunit;
26-
27-
public class CredentialTests : AutomationScenarioTestsBase
20+
public class CredentialTests : AutomationTestRunner
2821
{
29-
public XunitTracingInterceptor logger;
30-
3122
public CredentialTests(Xunit.Abstractions.ITestOutputHelper output)
23+
: base(output)
3224
{
33-
logger = new XunitTracingInterceptor(output);
34-
XunitTracingInterceptor.AddToContext(logger);
3525
}
3626

3727
[Fact]
@@ -41,7 +31,7 @@ public CredentialTests(Xunit.Abstractions.ITestOutputHelper output)
4131
[Trait(Category.AcceptanceType, Category.BVT)]
4232
public void TestE2ECRedentials()
4333
{
44-
RunPowerShellTest(logger, "Test-E2ECredentials");
34+
TestRunner.RunTestScript("Test-E2ECredentials");
4535
}
4636
}
4737
}

0 commit comments

Comments
 (0)