Using the latest xunit skip condition attributes to skip tests

Also moved all the helper code into sub-directories.
This commit is contained in:
Praburaj 2014-12-18 17:42:12 -08:00
parent 102270d8db
commit 9c442e97ff
18 changed files with 169 additions and 115 deletions

View File

@ -2,31 +2,30 @@
"authors": [
"Microsoft"
],
"description": "Music store application on K",
"description": "Music store application on ASP.NET 5",
"version": "1.0.0-*",
"compilationOptions": { "warningsAsErrors": true, "define": [ "DEMO", "TESTING" ] },
"packExclude": "*.cmd",
"webroot": "wwwroot",
"dependencies": {
"EntityFramework.SqlServer": "7.0.0-*",
"EntityFramework.InMemory": "7.0.0-*", //For Mono
"Kestrel": "1.0.0-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.AspNet.Diagnostics": "1.0.0-*",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Security.Cookies": "1.0.0-*",
"Microsoft.AspNet.Security.Facebook": "1.0.0-*",
"Microsoft.AspNet.Security.Google": "1.0.0-*",
"Microsoft.AspNet.Security.MicrosoftAccount": "1.0.0-*",
"Microsoft.AspNet.Security.Twitter": "1.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"EntityFramework.SqlServer": "7.0.0-*",
/*For Mono*/
"EntityFramework.InMemory": "7.0.0-*",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*",
"Microsoft.Framework.OptionsModel": "1.0.0-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.AspNet.SignalR.Server": "3.0.0-*",
"Microsoft.Framework.Cache.Memory": "1.0.0-*"
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.Framework.Cache.Memory": "1.0.0-*",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*",
"Microsoft.Framework.OptionsModel": "1.0.0-*"
},
"commands": {
"WebListener": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5002",
@ -37,4 +36,4 @@
"aspnet50": { },
"aspnetcore50": { }
}
}
}

View File

@ -173,7 +173,7 @@ namespace E2ETests
var klrMonoManaged = Path.Combine(kreBin, "klr.mono.managed.dll");
var applicationHost = Path.Combine(kreBin, "Microsoft.Framework.ApplicationHost");
Console.WriteLine(string.Format("Executing command: {0} {1} {2} {3} {4}", monoPath, klrMonoManaged, startParameters.ApplicationPath, applicationHost, startParameters.ServerType.ToString()));
Console.WriteLine(string.Format("Executing command: {0} {1} {2} {3}", monoPath, klrMonoManaged, applicationHost, startParameters.ServerType.ToString()));
var startInfo = new ProcessStartInfo
{

View File

@ -0,0 +1,15 @@
using System;
namespace E2ETests
{
public class Helpers
{
public static bool RunningOnMono
{
get
{
return Type.GetType("Mono.Runtime") != null;
}
}
}
}

View File

@ -1,60 +0,0 @@
using System;
namespace E2ETests
{
public class Helpers
{
public static bool RunningOnMono
{
get
{
return Type.GetType("Mono.Runtime") != null;
}
}
public static bool SkipTestOnCurrentConfiguration(bool RunTestOnMono, KreArchitecture architecture, ServerType serverType)
{
if (RunTestOnMono && !RunningOnMono)
{
//Skip Mono variations on Windows
Console.WriteLine("Skipping mono variation on .NET");
return true;
}
if (!RunTestOnMono && RunningOnMono)
{
//Skip .net variations on mono
Console.WriteLine("Skipping .NET variation on mono");
return true;
}
// Check if processor architecture is x64, else skip test
if (architecture == KreArchitecture.amd64 && !Environment.Is64BitOperatingSystem)
{
Console.WriteLine("Skipping x64 test since machine is of type x86");
return true;
}
if (serverType == ServerType.IISNativeModule &&
!(Environment.OSVersion.Version.Major >= 6 && Environment.OSVersion.Version.Minor >= 2))
{
// Works only on 6.2 and above
Console.WriteLine("Skipping Native module test since machine is not Win2012R2/Win8.1 and above");
return true;
}
if (serverType == ServerType.IISNativeModule &&
Environment.GetEnvironmentVariable("IIS_NATIVE_MODULE_SETUP") != "true")
{
// Native module variations require IIS setup. Once native module is setup on IIS, set the value of the environment
// variable to true to run the native module variation.
// TODO: Need a better way to detect native module on the machine.
Console.WriteLine("Skipping Native module test since native module is not installed on IIS.");
Console.WriteLine("Setup the native module and set the IIS_NATIVE_MODULE_SETUP to true to run the variation.");
return true;
}
return false;
}
}
}

View File

@ -2,13 +2,15 @@
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using Microsoft.AspNet.Testing.xunit;
using Xunit;
namespace E2ETests
{
public partial class SmokeTests
{
[Theory]
[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Unix | OperatingSystems.MacOSX)]
[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5001/")]
[InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5001/")]
[InlineData(ServerType.WebListener, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5002/")]
@ -16,12 +18,6 @@ namespace E2ETests
{
Console.WriteLine("Variation Details : HostType = {0}, KreFlavor = {1}, Architecture = {2}, applicationBaseUrl = {3}", serverType, kreFlavor, architecture, applicationBaseUrl);
if (Helpers.SkipTestOnCurrentConfiguration(false, architecture, serverType))
{
Assert.True(true);
return;
}
startParameters = new StartParameters
{
ServerType = serverType,

View File

@ -4,28 +4,44 @@ using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading;
using Microsoft.AspNet.Testing.xunit;
using Xunit;
namespace E2ETests
{
public partial class SmokeTests
{
[Theory]
[InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/", false)]
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5002/", false)]
[ConditionalTheory]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/")]
public void Publish_And_Run_Tests_On_X86(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
{
Publish_And_Run_Tests(serverType, kreFlavor, architecture, applicationBaseUrl);
}
[ConditionalTheory]
[FrameworkSkipCondition(RuntimeFrameworks.DotNet)]
[InlineData(ServerType.Kestrel, KreFlavor.Mono, KreArchitecture.x86, "http://localhost:5004/")]
public void Publish_And_Run_Tests_On_Mono(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
{
Publish_And_Run_Tests(serverType, kreFlavor, architecture, applicationBaseUrl);
}
[ConditionalTheory]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[InlineData(ServerType.Kestrel, KreFlavor.Mono, KreArchitecture.x86, "http://localhost:5004/")]
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5002/")]
//https://github.com/aspnet/KRuntime/issues/642
//[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5001/", false)]
[InlineData(ServerType.Kestrel, KreFlavor.Mono, KreArchitecture.x86, "http://localhost:5004/", true)]
public void PublishAndRunTests(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl, bool runTestOnMono = false)
//[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5001/")]
public void Publish_And_Run_Tests_On_AMD64(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
{
Publish_And_Run_Tests(serverType, kreFlavor, architecture, applicationBaseUrl);
}
private void Publish_And_Run_Tests(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
{
Console.WriteLine("Variation Details : HostType = {0}, KreFlavor = {1}, Architecture = {2}, applicationBaseUrl = {3}", serverType, kreFlavor, architecture, applicationBaseUrl);
if (Helpers.SkipTestOnCurrentConfiguration(runTestOnMono, architecture, serverType))
{
Assert.True(true);
return;
}
startParameters = new StartParameters
{
ServerType = serverType,

View File

@ -3,6 +3,7 @@ using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Threading;
using Microsoft.AspNet.Testing.xunit;
using Xunit;
namespace E2ETests
@ -16,29 +17,63 @@ namespace E2ETests
private HttpClientHandler httpClientHandler;
private StartParameters startParameters;
[Theory]
[InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/", false)]
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5002/", false)]
[InlineData(ServerType.Kestrel, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5004/", false)]
[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5001/", false)]
[InlineData(ServerType.WebListener, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5002/", false)]
[InlineData(ServerType.Kestrel, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5004/", false)]
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5002/", false)]
[InlineData(ServerType.Kestrel, KreFlavor.Mono, KreArchitecture.x86, "http://localhost:5004/", true)]
[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5001/", false)]
[InlineData(ServerType.Kestrel, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5004/", false)]
[InlineData(ServerType.IISNativeModule, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5005/", false)]
[InlineData(ServerType.IISNativeModule, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5005/", false)]
public void SmokeTestSuite(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl, bool runTestOnMono)
[ConditionalTheory]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[InlineData(ServerType.Helios, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5001/")]
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5002/")]
[InlineData(ServerType.Kestrel, KreFlavor.DesktopClr, KreArchitecture.x86, "http://localhost:5004/")]
[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5001/")]
[InlineData(ServerType.WebListener, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5002/")]
[InlineData(ServerType.Kestrel, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5004/")]
public void SmokeTestSuite_OnX86(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
{
SmokeTestSuite(serverType, kreFlavor, architecture, applicationBaseUrl);
}
[ConditionalTheory]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[SkipOn32BitOS]
[InlineData(ServerType.WebListener, KreFlavor.DesktopClr, KreArchitecture.amd64, "http://localhost:5002/")]
[InlineData(ServerType.Helios, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5001/")]
[InlineData(ServerType.Kestrel, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5004/")]
public void SmokeTestSuite_OnAMD64(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
{
SmokeTestSuite(serverType, kreFlavor, architecture, applicationBaseUrl);
}
[ConditionalTheory]
[FrameworkSkipCondition(RuntimeFrameworks.DotNet)]
[InlineData(ServerType.Kestrel, KreFlavor.Mono, KreArchitecture.x86, "http://localhost:5004/")]
public void SmokeTestSuite_OnMono(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
{
SmokeTestSuite(serverType, kreFlavor, architecture, applicationBaseUrl);
}
[ConditionalTheory]
[SkipIfNativeModuleNotInstalled]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[OSSkipCondition(OperatingSystems.Win7And2008R2 | OperatingSystems.MacOSX | OperatingSystems.Unix)]
[InlineData(ServerType.IISNativeModule, KreFlavor.CoreClr, KreArchitecture.x86, "http://localhost:5005/")]
public void SmokeTestSuite_On_NativeModule_X86(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
{
SmokeTestSuite(serverType, kreFlavor, architecture, applicationBaseUrl);
}
[ConditionalTheory]
[SkipIfNativeModuleNotInstalled]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[OSSkipCondition(OperatingSystems.Win7And2008R2 | OperatingSystems.MacOSX | OperatingSystems.Unix)]
[SkipOn32BitOS]
[InlineData(ServerType.IISNativeModule, KreFlavor.CoreClr, KreArchitecture.amd64, "http://localhost:5005/")]
public void SmokeTestSuite_On_NativeModule_AMD64(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
{
SmokeTestSuite(serverType, kreFlavor, architecture, applicationBaseUrl);
}
private void SmokeTestSuite(ServerType serverType, KreFlavor kreFlavor, KreArchitecture architecture, string applicationBaseUrl)
{
Console.WriteLine("Variation Details : HostType = {0}, KreFlavor = {1}, Architecture = {2}, applicationBaseUrl = {3}", serverType, kreFlavor, architecture, applicationBaseUrl);
if (Helpers.SkipTestOnCurrentConfiguration(runTestOnMono, architecture, serverType))
{
Assert.True(true);
return;
}
startParameters = new StartParameters
{
ServerType = serverType,

View File

@ -1,13 +1,14 @@
{
"compilationOptions": { "warningsAsErrors": "true" },
"compilationOptions": { "warningsAsErrors": true },
"commands": {
"test": "xunit.runner.kre"
},
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
"Microsoft.Framework.Runtime.Interfaces": "1.0.0-*",
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
"Microsoft.AspNet.SignalR.Client": "2.1.1",
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
"Microsoft.Framework.Runtime.Interfaces": "1.0.0-*",
"Microsoft.Web.Administration": "7.0.0",
"xunit.runner.kre": "1.0.0-*"
},

View File

@ -0,0 +1,27 @@
using System;
using Microsoft.AspNet.Testing.xunit;
namespace E2ETests
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class SkipIfNativeModuleNotInstalledAttribute : Attribute, ITestCondition
{
public bool IsMet
{
get
{
// TODO: Need a better way to detect native module on the machine.
return Environment.GetEnvironmentVariable("IIS_NATIVE_MODULE_SETUP") == "true";
}
}
public string SkipReason
{
get
{
return "Skipping Native module test since native module is not installed on IIS. " +
"To run the test, setup the native module and set the environment variable IIS_NATIVE_MODULE_SETUP=true.";
}
}
}
}

View File

@ -0,0 +1,25 @@
using System;
using Microsoft.AspNet.Testing.xunit;
namespace E2ETests
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class SkipOn32BitOSAttribute : Attribute, ITestCondition
{
public bool IsMet
{
get
{
return Environment.Is64BitOperatingSystem;
}
}
public string SkipReason
{
get
{
return "Skipping the AMD64 test since the OS is 32-bit";
}
}
}
}