Skip to content

Grouped xunit tests together #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions AzurePowershell.Test.targets
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,35 @@
<AzureRTSeqAllFilter>"AzureRTUpload|Sequential|Network"</AzureRTSeqAllFilter>
</PropertyGroup>

<ItemGroup>
<XUnitTests Include=".\src\Common\Commands.Common.Test\bin\Debug\Microsoft.WindowsAzure.Commands.Common.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\Sql\Commands.Sql.Test\bin\Debug\Microsoft.Azure.Commands.Sql.Test.dll"/>
<XUnitTests Include=".\src\ServiceManagement\Services\Commands.Test\bin\Debug\Microsoft.WindowsAzure.Commands.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\Resources\Commands.Resources.Test\bin\Debug\Microsoft.Azure.Commands.Resources.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\DataFactories\Commands.DataFactories.Test\bin\Debug\Microsoft.Azure.Commands.DataFactories.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\StreamAnalytics\Commands.StreamAnalytics.Test\bin\Debug\Microsoft.Azure.Commands.StreamAnalytics.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\Batch\Commands.Batch.Test\bin\Debug\Microsoft.Azure.Commands.Batch.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\KeyVault\Commands.KeyVault.Test\bin\Debug\Microsoft.Azure.Commands.KeyVault.Test.dll"/>
<XUnitTests Include=".\src\ServiceManagement\ManagedCache\Commands.ManagedCache.Test\bin\Debug\Microsoft.Azure.Commands.ManagedCache.Test.dll"/>
<XUnitTests Include=".\src\Common\Commands.ScenarioTest\bin\Debug\Microsoft.WindowsAzure.Commands.ScenarioTest.dll"/>
<XUnitTests Include=".\src\ServiceManagement\RecoveryServices\Commands.RecoveryServices.Test\bin\Debug\Microsoft.Azure.Commands.RecoveryServices.Test.dll"/>
<XUnitTests Include=".\src\ServiceManagement\StorSimple\Commands.StorSimple.Test\bin\Debug\Microsoft.WindowsAzure.Commands.StorSimple.Test.dll"/>
</ItemGroup>

<Target Name="InvokeMSTest">
<!--Remove existing test result; otherwsie mstest will error-->
<Delete Files="$(_testResult)"/>
<Exec
Command="MSTest.exe /testcontainer:$(_testAssembly) /testsettings:$(_testSettings) /category:$(_testFilter) /resultsfile:$(_testResult)"
ContinueOnError="false" />
</Target>

<Target Name="InvokeXUnit">
<Message Importance="high" Text="Running XUnit tests" />
<MakeDir Directories="$(TestOutputDirectory)" ContinueOnError="false" />
<Xunit.Runner.MSBuild.xunit Assemblies="@(XUnitTests)" Html="$(TestOutputDirectory)\xunit.tests.dll.html" Verbose="true"
ExcludeTraits="$(XUnitExcludedTrait)" MaxParallelThreads="0" ParallelizeAssemblies="false" ParallelizeTestCollections="false"/>
</Target>

<Target Name="BeforeRunTests">
<Message Importance="high" Text="You are required to have installed a version of Visual Studio with support for MSTest (and MSTest on your path)." />
Expand Down
7 changes: 6 additions & 1 deletion build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<TestOutputDirectory>$(PublishDirectory)\TestResults</TestOutputDirectory>
<DebugBuildConfig>Configuration=Debug;Platform=Any CPU</DebugBuildConfig>
<ReleaseBuildConfig>Configuration=Release;Platform=Any CPU</ReleaseBuildConfig>
<BuildInParallel Condition="'$(BuildInParallel)' == ''">true</BuildInParallel>
</PropertyGroup>
<ItemGroup>
<AzurePowerShellSln Include=".\src\AzurePowerShell.sln" />
Expand Down Expand Up @@ -104,11 +105,13 @@
Projects="@(AzurePowerShellSln)"
Targets="Build"
Properties="$(DebugBuildConfig)"
BuildInParallel="$(BuildInParallel)"
ContinueOnError="false" />
<MSBuild
Projects="@(AzurePowerShellSln)"
Targets="Build"
Properties="$(ReleaseBuildConfig)"
BuildInParallel="$(BuildInParallel)"
ContinueOnError="false" />
</Target>

Expand Down Expand Up @@ -160,6 +163,7 @@
Projects="@(AzurePowerShellSln)"
Targets="Build"
Properties="$(ReleaseBuildConfig)"
BuildInParallel="$(BuildInParallel)"
ContinueOnError="false" />
</Target>

Expand All @@ -170,6 +174,7 @@
Projects="@(AzurePowerShellSln)"
Targets="Build"
Properties="$(DebugBuildConfig)"
BuildInParallel="$(BuildInParallel)"
ContinueOnError="false" />
</Target>

Expand All @@ -183,7 +188,7 @@
<!-- Run checkin tests for each pull request -->
<Target Name="Test" DependsOnTargets="BuildDebug;BeforeRunTests">
<Message Importance="high" Text="Running check in tests..." />
<CallTarget Targets="KeyVaultTests; SqlTests; CommonTests; TestManagement; TestHDInsight; TestManagedCache; TestServiceManagement; TestServiceManagementExtensions; TestSqlDatabase; TestStorage; TestResourceManager; MockedScenarioTests; TestDSCExtension_x64; TestBatch; TestDataFactoryManager; TestRecoveryServices; TestStreamAnalyticsManager; TestStorSimple"/>
<CallTarget Targets="InvokeXUnit; TestHDInsight; TestServiceManagement; TestServiceManagementExtensions; TestSqlDatabase; TestStorage; TestDSCExtension_x64"/>
</Target>

<!-- Run Full switch with scenario tests -->
Expand Down
44 changes: 44 additions & 0 deletions src/Common/Commands.Common.Test/Common/ProfileCmdltsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,50 @@ public void SelectAzureSubscriptionByNameUpdatesProfile()
Assert.Equal(azureSubscription2.Id, cmdlt.Profile.Context.Subscription.Id);
}

[Fact]
public void SelectAzureSubscriptionByNameWithoutAccountPreservesTheAccount()
{
SetupDefaultProfile();
SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand();

// Setup
cmdlt.CommandRuntime = commandRuntimeMock;
cmdlt.SetParameterSet("SelectSubscriptionByNameParameterSet");
cmdlt.SubscriptionName = azureSubscription2.Name;

// Act
cmdlt.InvokeBeginProcessing();
cmdlt.ExecuteCmdlet();
cmdlt.InvokeEndProcessing();

// Verify
Assert.NotNull(cmdlt.Profile.Context.Subscription);
Assert.Equal(azureSubscription2.Account, cmdlt.Profile.Context.Subscription.Account);
Assert.Equal(azureSubscription2.Id, cmdlt.Profile.Context.Subscription.Id);
}

[Fact]
public void SelectAzureSubscriptionByIdWithoutAccountPreservesTheAccount()
{
SetupDefaultProfile();
SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand();

// Setup
cmdlt.CommandRuntime = commandRuntimeMock;
cmdlt.SetParameterSet("SelectSubscriptionByIdParameterSet");
cmdlt.SubscriptionId = azureSubscription2.Id.ToString();

// Act
cmdlt.InvokeBeginProcessing();
cmdlt.ExecuteCmdlet();
cmdlt.InvokeEndProcessing();

// Verify
Assert.NotNull(cmdlt.Profile.Context.Subscription);
Assert.Equal(azureSubscription2.Account, cmdlt.Profile.Context.Subscription.Account);
Assert.Equal(azureSubscription2.Id, cmdlt.Profile.Context.Subscription.Id);
}

[Fact]
public void SelectAzureSubscriptionWithoutPassthroughDoesNotPrint()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// ----------------------------------------------------------------------------------

using System;
using System.Linq;
using System.Management.Automation;
using Microsoft.WindowsAzure.Commands.Common;
using Microsoft.Azure.Common.Authentication.Models;
Expand Down Expand Up @@ -94,20 +95,20 @@ public override void ExecuteCmdlet()
switch (ParameterSetName)
{
case SelectSubscriptionByNameParameterSet:
azureSubscription = ProfileClient.SetSubscriptionAsDefault(SubscriptionName, Account);
azureSubscription = ProfileClient.SetSubscriptionAsDefault(SubscriptionName, GetAccount());
break;

case SelectSubscriptionByIdParameterSet:
azureSubscription = ProfileClient.SetSubscriptionAsDefault(SubscriptionIdAsGuid(), Account);
azureSubscription = ProfileClient.SetSubscriptionAsDefault(SubscriptionIdAsGuid(), GetAccount());
break;

case SelectDefaultSubscriptionByNameParameterSet:
azureSubscription = ProfileClient.SetSubscriptionAsDefault(SubscriptionName, Account);
azureSubscription = ProfileClient.SetSubscriptionAsDefault(SubscriptionName, GetAccount());
WriteWarning("Current and Default parameters have been deprecated. Select-AzureSubscription will always update the Default Subscription.");
break;

case SelectDefaultSubscriptionByIdParameterSet:
azureSubscription = ProfileClient.SetSubscriptionAsDefault(SubscriptionIdAsGuid(), Account);
azureSubscription = ProfileClient.SetSubscriptionAsDefault(SubscriptionIdAsGuid(), GetAccount());
WriteWarning("Current and Default parameters have been deprecated. Select-AzureSubscription will always update the Default Subscription.");
break;

Expand All @@ -126,6 +127,31 @@ public override void ExecuteCmdlet()
}
}

/// <summary>
/// Returns Account specified in the parameter or current account of the subscription
/// </summary>
/// <returns></returns>
private string GetAccount()
{
if (!string.IsNullOrEmpty(Account))
{
return Account;
}

AzureSubscription subscription = ProfileClient.Profile.Subscriptions.Values
.FirstOrDefault(s => s.Name.Equals(SubscriptionName, StringComparison.InvariantCultureIgnoreCase) ||
s.Id.ToString().Equals(SubscriptionId, StringComparison.InvariantCultureIgnoreCase));

if (subscription != null)
{
return subscription.Account;
}
else
{
return null;
}
}

private Guid SubscriptionIdAsGuid()
{
Guid subscriptionIdGuid;
Expand Down