public ClientTestRunConfiguration(UnitTestProviderType unitTestProviderType, IEnumerable <string> methodsToTest, string tagFilters, int numberOfBrowserHosts, WebBrowserType webBrowserType, string entryPointAssembly, WindowGeometry windowGeometry, IEnumerable <string> testAssemblyFormalNames) { if (methodsToTest == null) { throw new ArgumentNullException("methodsToTest"); } if (entryPointAssembly == null) { throw new ArgumentNullException("entryPointAssembly"); } if (unitTestProviderType == UnitTestProviderType.Undefined) { throw new ArgumentException("Must be defined", "unitTestProviderType"); } if (numberOfBrowserHosts <= 0) { throw new ArgumentOutOfRangeException("numberOfBrowserHosts", "Must be greater than 0"); } //if (testAssemblyFormalNames.Count() == 0) // throw new ArgumentException("must have some assemblies specified", "testAssemblyFormalNames"); _methodsToTest = methodsToTest.ToCollection(); _tagFilters = tagFilters ?? string.Empty; UnitTestProviderType = unitTestProviderType; NumberOfBrowserHosts = numberOfBrowserHosts; WebBrowserType = webBrowserType; EntryPointAssembly = entryPointAssembly; WindowGeometry = windowGeometry; _testAssemblyFormalNames = new Collection <string>(testAssemblyFormalNames.ToList()); }
public StatLightConfiguration GetStatLightConfigurationForDll(UnitTestProviderType unitTestProviderType, string dllPath, MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion, Collection <string> methodsToTest, string tagFilters, int numberOfBrowserHosts, bool isRemoteRun, string queryString, WebBrowserType webBrowserType, bool forceBrowserStart, bool showTestingBrowserHost) { if (queryString == null) { throw new ArgumentNullException("queryString"); } Func <IEnumerable <ITestFile> > filesToCopyIntoHostXap = () => new List <ITestFile>(); string entryPointAssembly = string.Empty; string runtimeVersion = null; if (isRemoteRun) { } else { AssertFileExists(dllPath); var dllFileInfo = new FileInfo(dllPath); var assemblyResolver = new AssemblyResolver(_logger); var dependentAssemblies = assemblyResolver.ResolveAllDependentAssemblies(dllFileInfo.FullName); var coreFileUnderTest = new TestFile(dllFileInfo.FullName); var dependentFilesUnderTest = dependentAssemblies.Select(file => new TestFile(file)).ToList(); dependentFilesUnderTest.Add(coreFileUnderTest); var xapReadItems = new TestFileCollection(_logger, AssemblyName.GetAssemblyName(dllFileInfo.FullName).ToString(), dependentFilesUnderTest); SetupUnitTestProviderType(xapReadItems, ref unitTestProviderType, ref microsoftTestingFrameworkVersion); entryPointAssembly = xapReadItems.TestAssemblyFullName; filesToCopyIntoHostXap = () => { return(new TestFileCollection(_logger, AssemblyName.GetAssemblyName(dllFileInfo.FullName) .ToString(), dependentFilesUnderTest).FilesContainedWithinXap); }; } var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly); var serverConfig = CreateServerConfiguration( dllPath, clientConfig.UnitTestProviderType, microsoftTestingFrameworkVersion, filesToCopyIntoHostXap, DefaultDialogSmackDownElapseMilliseconds, queryString, forceBrowserStart, showTestingBrowserHost, runtimeVersion); return(new StatLightConfiguration(clientConfig, serverConfig)); }
private void SetupUnitTestProvider(UnitTestProviderType unitTestProviderType) { Microsoft.Silverlight.Testing.UnitTesting.Metadata.UnitTestProviders.Providers.Clear(); #if !WINDOWS_PHONE if (unitTestProviderType == UnitTestProviderType.XUnitLight) { UnitTestSystem.RegisterUnitTestProvider(new StatLight.Client.Harness.Hosts.MSTest.UnitTestProviders.Xunit.XUnitTestProvider()); } else if (unitTestProviderType == UnitTestProviderType.NUnit) { UnitTestSystem.RegisterUnitTestProvider(new StatLight.Client.Harness.Hosts.MSTest.UnitTestProviders.NUnit.NUnitTestProvider()); } else if (unitTestProviderType == UnitTestProviderType.UnitDriven) { UnitTestSystem.RegisterUnitTestProvider(new StatLight.Client.Harness.Hosts.MSTest.UnitTestProviders.UnitDriven.UnitDrivenTestProvider()); } else if (unitTestProviderType == UnitTestProviderType.MSTestWithCustomProvider) { System.Type interfaceLookingFor = typeof(Microsoft.Silverlight.Testing.UnitTesting.Metadata.IUnitTestProvider); var allProviderPossibilities = (from assembly in _loadedXapData.TestAssemblies from type in assembly.GetTypes() where interfaceLookingFor.IsAssignableFrom(type) && !type.IsAbstract && type != typeof(Microsoft.Silverlight.Testing.UnitTesting.Metadata.VisualStudio.VsttProvider) select type).ToList(); if (allProviderPossibilities.Count == 1) { var customProviderType = allProviderPossibilities.First(); var instance = System.Activator.CreateInstance(customProviderType); var provider = (Microsoft.Silverlight.Testing.UnitTesting.Metadata.IUnitTestProvider)instance; UnitTestSystem.RegisterUnitTestProvider(provider); } else { if (allProviderPossibilities.Any()) { var providers = string.Join(Environment.NewLine, allProviderPossibilities.Select(x => x.FullName).ToArray()); // TODO: how to handle this??? throw new StatLightException("Multiple unit test provider types where present in the xap, but only one was expected. The types found were: " + Environment.NewLine + providers); } throw new StatLightException("Could not find any classes that inherit from IUnitTestProvider."); } } else #endif { UnitTestSystem.RegisterUnitTestProvider(new StatLight.Client.Harness.Hosts.MSTest.UnitTestProviders.MSTest.VsttProvider()); } }
public StatLightConfiguration GetStatLightConfigurationForDll(UnitTestProviderType unitTestProviderType, string dllPath, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, Collection<string> methodsToTest, string tagFilters, int numberOfBrowserHosts, bool isRemoteRun, string queryString, WebBrowserType webBrowserType, bool forceBrowserStart, bool showTestingBrowserHost) { if (queryString == null) throw new ArgumentNullException("queryString"); Func<IEnumerable<ITestFile>> filesToCopyIntoHostXap = () => new List<ITestFile>(); string entryPointAssembly = string.Empty; string runtimeVersion = null; if (isRemoteRun) { } else { AssertFileExists(dllPath); var dllFileInfo = new FileInfo(dllPath); var assemblyResolver = new AssemblyResolver(_logger); var dependentAssemblies = assemblyResolver.ResolveAllDependentAssemblies(dllFileInfo.FullName); var coreFileUnderTest = new TestFile(dllFileInfo.FullName); var dependentFilesUnderTest = dependentAssemblies.Select(file => new TestFile(file)).ToList(); dependentFilesUnderTest.Add(coreFileUnderTest); var xapReadItems = new TestFileCollection(_logger, AssemblyName.GetAssemblyName(dllFileInfo.FullName).ToString(), dependentFilesUnderTest); SetupUnitTestProviderType(xapReadItems, ref unitTestProviderType, ref microsoftTestingFrameworkVersion); entryPointAssembly = xapReadItems.TestAssemblyFullName; filesToCopyIntoHostXap =()=> { return new TestFileCollection(_logger, AssemblyName.GetAssemblyName(dllFileInfo.FullName) .ToString(), dependentFilesUnderTest).FilesContainedWithinXap; }; } var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly); var serverConfig = CreateServerConfiguration( dllPath, clientConfig.UnitTestProviderType, microsoftTestingFrameworkVersion, filesToCopyIntoHostXap, DefaultDialogSmackDownElapseMilliseconds, queryString, forceBrowserStart, showTestingBrowserHost, runtimeVersion); return new StatLightConfiguration(clientConfig, serverConfig); }
public StatLightConfiguration GetStatLightConfigurationForXap(UnitTestProviderType unitTestProviderType, string xapPath, MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion, Collection <string> methodsToTest, string tagFilters, int numberOfBrowserHosts, bool isRemoteRun, string queryString, WebBrowserType webBrowserType, bool forceBrowserStart, bool showTestingBrowserHost) { if (queryString == null) { throw new ArgumentNullException("queryString"); } if (showTestingBrowserHost && !Environment.UserInteractive) { throw new StatLightException("You cannot use the -b option as your C.I. server's agent process is not running in desktop interactive mode."); } Func <IEnumerable <ITestFile> > filesToCopyIntoHostXap = () => new List <ITestFile>(); string runtimeVersion = null; string entryPointAssembly = string.Empty; if (isRemoteRun) { } else { AssertFileExists(xapPath); var xapReader = new XapReader(_logger); TestFileCollection testFileCollection = xapReader.LoadXapUnderTest(xapPath); runtimeVersion = XapReader.GetRuntimeVersion(xapPath); SetupUnitTestProviderType(testFileCollection, ref unitTestProviderType, ref microsoftTestingFrameworkVersion); entryPointAssembly = testFileCollection.TestAssemblyFullName; filesToCopyIntoHostXap = () => { return(xapReader.LoadXapUnderTest(xapPath).FilesContainedWithinXap); }; } var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly); var serverConfig = CreateServerConfiguration( xapPath, clientConfig.UnitTestProviderType, microsoftTestingFrameworkVersion, filesToCopyIntoHostXap, DefaultDialogSmackDownElapseMilliseconds, queryString, forceBrowserStart, showTestingBrowserHost, runtimeVersion); return(new StatLightConfiguration(clientConfig, serverConfig)); }
private StatLightConfiguration GetStatLightConfigurationForDll(string dllPath) { Func <IEnumerable <ITestFile> > filesToCopyIntoHostXap = () => new List <ITestFile>(); string entryPointAssembly = string.Empty; string runtimeVersion = null; IEnumerable <string> testAssemblyFormalNames = new List <string>(); var dllFileInfo = new FileInfo(dllPath); var assemblyResolver = new AssemblyResolver(); var dependentAssemblies = assemblyResolver.ResolveAllDependentAssemblies(_options.IsPhoneRun, dllFileInfo.FullName); var coreFileUnderTest = new TestFile(dllFileInfo.FullName); var dependentFilesUnderTest = dependentAssemblies.Select(file => new TestFile(file)).ToList(); dependentFilesUnderTest.Add(coreFileUnderTest); var testFileCollection = new TestFileCollection(_logger, AssemblyName.GetAssemblyName(dllFileInfo.FullName).ToString(), dependentFilesUnderTest); testAssemblyFormalNames = testFileCollection.GetAssemblyNames(); UnitTestProviderType unitTestProviderType = _options.UnitTestProviderType; MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion = _options.MicrosoftTestingFrameworkVersion; SetupUnitTestProviderType(testFileCollection, ref unitTestProviderType, ref microsoftTestingFrameworkVersion); entryPointAssembly = testFileCollection.TestAssemblyFullName; filesToCopyIntoHostXap = () => { return(new TestFileCollection(_logger, AssemblyName.GetAssemblyName(dllFileInfo.FullName) .ToString(), dependentFilesUnderTest).FilesContainedWithinXap); }; var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, _options.MethodsToTest, _options.TagFilters, _options.NumberOfBrowserHosts, _options.WebBrowserType, entryPointAssembly, _options.WindowGeometry, testAssemblyFormalNames); var serverConfig = CreateServerConfiguration( dllPath, clientConfig.UnitTestProviderType, microsoftTestingFrameworkVersion, filesToCopyIntoHostXap, _options.QueryString, _options.ForceBrowserStart, _options.WindowGeometry, runtimeVersion, _options.IsPhoneRun); return(new StatLightConfiguration(clientConfig, serverConfig)); }
private StatLightConfiguration GetStatLightConfigurationForXap(string xapPath) { Func <IEnumerable <ITestFile> > filesToCopyIntoHostXap = () => new List <ITestFile>(); string runtimeVersion = null; IEnumerable <string> testAssemblyFormalNames = new List <string>(); string entryPointAssembly = string.Empty; var xapReader = new XapReader(_logger); TestFileCollection testFileCollection = xapReader.LoadXapUnderTest(xapPath); runtimeVersion = XapReader.GetRuntimeVersion(xapPath); UnitTestProviderType unitTestProviderType = _options.UnitTestProviderType; MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion = _options.MicrosoftTestingFrameworkVersion; SetupUnitTestProviderType(testFileCollection, ref unitTestProviderType, ref microsoftTestingFrameworkVersion); entryPointAssembly = testFileCollection.TestAssemblyFullName; testAssemblyFormalNames = testFileCollection.GetAssemblyNames(); filesToCopyIntoHostXap = () => { return(xapReader.LoadXapUnderTest(xapPath).FilesContainedWithinXap); }; var clientConfig = new ClientTestRunConfiguration( unitTestProviderType: unitTestProviderType, methodsToTest: _options.MethodsToTest, tagFilters: _options.TagFilters, numberOfBrowserHosts: _options.NumberOfBrowserHosts, webBrowserType: _options.WebBrowserType, entryPointAssembly: entryPointAssembly, windowGeometry: _options.WindowGeometry, testAssemblyFormalNames: testAssemblyFormalNames); var serverConfig = CreateServerConfiguration( xapPath, unitTestProviderType, microsoftTestingFrameworkVersion, filesToCopyIntoHostXap, _options.QueryString, _options.ForceBrowserStart, _options.WindowGeometry, runtimeVersion, _options.IsPhoneRun); return(new StatLightConfiguration(clientConfig, serverConfig)); }
public ClientTestRunConfiguration(UnitTestProviderType unitTestProviderType, IEnumerable<string> methodsToTest, string tagFilters, int numberOfBrowserHosts, WebBrowserType webBrowserType, bool showTestingBrowserHost, string entryPointAssembly) { if (methodsToTest == null) throw new ArgumentNullException("methodsToTest"); if (unitTestProviderType == UnitTestProviderType.Undefined) throw new ArgumentException("Must be defined", "unitTestProviderType"); if (numberOfBrowserHosts <= 0) throw new ArgumentOutOfRangeException("numberOfBrowserHosts", "Must be greater than 0"); _methodsToTest = methodsToTest.ToCollection(); _tagFilters = tagFilters ?? string.Empty; UnitTestProviderType = unitTestProviderType; NumberOfBrowserHosts = numberOfBrowserHosts; WebBrowserType = webBrowserType; ShowTestingBrowserHost = showTestingBrowserHost; EntryPointAssembly = entryPointAssembly; }
public XapHostType MapToXapHostType(UnitTestProviderType unitTestProviderType, MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion) { Action throwNotSupportedException = () => { throw new NotSupportedException( "Cannot map to a xap host based on the following input values UnitTestProviderType={0}, MicrosoftTestingFrameworkVersion={1}" .FormatWith(unitTestProviderType, microsoftTestingFrameworkVersion)); }; switch (unitTestProviderType) { case UnitTestProviderType.NUnit: case UnitTestProviderType.XUnitLight: return(XapHostType.MSTest2010May); case UnitTestProviderType.MSTestWithCustomProvider: case UnitTestProviderType.MSTest: if (microsoftTestingFrameworkVersion.HasValue) { var msTestVersionXapHostStringName = microsoftTestingFrameworkVersion.Value.ToString(); if (Enum.IsDefined(typeof(XapHostType), msTestVersionXapHostStringName)) { return((XapHostType)Enum.Parse(typeof(XapHostType), msTestVersionXapHostStringName)); } } throwNotSupportedException(); break; case UnitTestProviderType.UnitDriven: return(XapHostType.UnitDriven2009December); case UnitTestProviderType.Xunit: return(XapHostType.XunitContrib2011April); case UnitTestProviderType.Undefined: default: throwNotSupportedException(); break; } return(XapHostType.UnitDriven2009December); }
public StatLightConfiguration GetStatLightConfigurationForXap(UnitTestProviderType unitTestProviderType, string xapPath, MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion, Collection <string> methodsToTest, string tagFilters, int numberOfBrowserHosts, bool isRemoteRun, string queryString, WebBrowserType webBrowserType, bool forceBrowserStart, bool showTestingBrowserHost) { if (queryString == null) { throw new ArgumentNullException("queryString"); } IEnumerable <ITestFile> filesToCopyIntoHostXap = new List <ITestFile>(); string entryPointAssembly = string.Empty; if (isRemoteRun) { } else { AssertFileExists(xapPath); var xapReader = new XapReader(_logger); TestFileCollection testFileCollection = xapReader.LoadXapUnderTest(xapPath); SetupUnitTestProviderType(testFileCollection, ref unitTestProviderType, ref microsoftTestingFrameworkVersion); entryPointAssembly = testFileCollection.TestAssemblyFullName; filesToCopyIntoHostXap = testFileCollection.FilesContainedWithinXap; } var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly); var serverConfig = CreateServerConfiguration( xapPath, clientConfig.UnitTestProviderType, microsoftTestingFrameworkVersion, filesToCopyIntoHostXap, DefaultDialogSmackDownElapseMilliseconds, queryString, forceBrowserStart, showTestingBrowserHost); return(new StatLightConfiguration(clientConfig, serverConfig)); }
public XapHostType MapToXapHostType(UnitTestProviderType unitTestProviderType, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion) { Action throwNotSupportedException = () => { throw new NotSupportedException( "Cannot map to a xap host based on the following input values UnitTestProviderType={0}, MicrosoftTestingFrameworkVersion={1}" .FormatWith(unitTestProviderType, microsoftTestingFrameworkVersion)); }; switch (unitTestProviderType) { case UnitTestProviderType.NUnit: case UnitTestProviderType.XUnitLight: return XapHostType.MSTestMay2010; case UnitTestProviderType.MSTestWithCustomProvider: case UnitTestProviderType.MSTest: if(microsoftTestingFrameworkVersion.HasValue) { var msTestVersionXapHostStringName = "MSTest" + microsoftTestingFrameworkVersion.Value; if (Enum.IsDefined(typeof(XapHostType), msTestVersionXapHostStringName)) return (XapHostType)Enum.Parse(typeof(XapHostType), msTestVersionXapHostStringName); } throwNotSupportedException(); break; case UnitTestProviderType.UnitDriven: return XapHostType.UnitDrivenDecember2009; case UnitTestProviderType.Xunit: return XapHostType.XunitContribApril2011; case UnitTestProviderType.Undefined: default: throwNotSupportedException(); break; } return XapHostType.UnitDrivenDecember2009; }
private ServerTestRunConfiguration CreateServerConfiguration( string xapPath, UnitTestProviderType unitTestProviderType, MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion, Func <IEnumerable <ITestFile> > filesToCopyIntoHostXapFunc, string queryString, bool forceBrowserStart, WindowGeometry windowGeometry, string runtimeVersion) { XapHostType xapHostType = _xapHostFileLoaderFactory.MapToXapHostType(unitTestProviderType, microsoftTestingFrameworkVersion); Func <byte[]> hostXapFactory = () => { byte[] hostXap = _xapHostFileLoaderFactory.LoadXapHostFor(xapHostType); hostXap = RewriteXapWithSpecialFiles(hostXap, filesToCopyIntoHostXapFunc, runtimeVersion); return(hostXap); }; return(new ServerTestRunConfiguration(hostXapFactory, xapPath, xapHostType, queryString, forceBrowserStart, windowGeometry)); }
private ServerTestRunConfiguration CreateServerConfiguration( string xapPath, UnitTestProviderType unitTestProviderType, MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion, IEnumerable <ITestFile> filesToCopyIntoHostXap, long dialogSmackDownElapseMilliseconds, string queryString, bool forceBrowserStart, bool showTestingBrowserHost) { XapHostType xapHostType = _xapHostFileLoaderFactory.MapToXapHostType(unitTestProviderType, microsoftTestingFrameworkVersion); Func <byte[]> hostXapFactory = () => { byte[] hostXap = _xapHostFileLoaderFactory.LoadXapHostFor(xapHostType); hostXap = RewriteXapWithSpecialFiles(hostXap, filesToCopyIntoHostXap); return(hostXap); }; return(new ServerTestRunConfiguration(hostXapFactory, dialogSmackDownElapseMilliseconds, xapPath, xapHostType, queryString, forceBrowserStart, showTestingBrowserHost)); }
private ServerTestRunConfiguration CreateServerConfiguration( string xapPath, UnitTestProviderType unitTestProviderType, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, Func<IEnumerable<ITestFile>> filesToCopyIntoHostXapFunc, string queryString, bool forceBrowserStart, WindowGeometry windowGeometry, string runtimeVersion) { XapHostType xapHostType = _xapHostFileLoaderFactory.MapToXapHostType(unitTestProviderType, microsoftTestingFrameworkVersion); Func<byte[]> hostXapFactory = () => { byte[] hostXap = _xapHostFileLoaderFactory.LoadXapHostFor(xapHostType); hostXap = RewriteXapWithSpecialFiles(hostXap, filesToCopyIntoHostXapFunc, runtimeVersion); return hostXap; }; return new ServerTestRunConfiguration(hostXapFactory, xapPath, xapHostType, queryString, forceBrowserStart, windowGeometry); }
public ClientTestRunConfiguration(UnitTestProviderType unitTestProviderType, IEnumerable<string> methodsToTest, string tagFilters, int numberOfBrowserHosts, WebBrowserType webBrowserType, string entryPointAssembly, WindowGeometry windowGeometry, IEnumerable<string> testAssemblyFormalNames) { if (methodsToTest == null) throw new ArgumentNullException("methodsToTest"); if (entryPointAssembly == null) throw new ArgumentNullException("entryPointAssembly"); if (unitTestProviderType == UnitTestProviderType.Undefined) throw new ArgumentException("Must be defined", "unitTestProviderType"); if (numberOfBrowserHosts <= 0) throw new ArgumentOutOfRangeException("numberOfBrowserHosts", "Must be greater than 0"); //if (testAssemblyFormalNames.Count() == 0) // throw new ArgumentException("must have some assemblies specified", "testAssemblyFormalNames"); _methodsToTest = methodsToTest.ToCollection(); _tagFilters = tagFilters ?? string.Empty; UnitTestProviderType = unitTestProviderType; NumberOfBrowserHosts = numberOfBrowserHosts; WebBrowserType = webBrowserType; EntryPointAssembly = entryPointAssembly; WindowGeometry = windowGeometry; _testAssemblyFormalNames = new Collection<string>(testAssemblyFormalNames.ToList()); }
private static void SetupUnitTestProviderType(TestFileCollection testFileCollection, ref UnitTestProviderType unitTestProviderType, ref MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion) { if (unitTestProviderType == UnitTestProviderType.Undefined || microsoftTestingFrameworkVersion == null) { //TODO: Print message telling the user what the type is - and if they give it // we don't have to "reflect" on the xap to determine the test provider type. if (unitTestProviderType == UnitTestProviderType.Undefined) { unitTestProviderType = testFileCollection.UnitTestProvider; } if ( (testFileCollection.UnitTestProvider == UnitTestProviderType.MSTest || unitTestProviderType == UnitTestProviderType.MSTest || unitTestProviderType == UnitTestProviderType.MSTestWithCustomProvider) && microsoftTestingFrameworkVersion == null) { microsoftTestingFrameworkVersion = testFileCollection.MSTestVersion; } } }
public ClientTestRunConfiguration(UnitTestProviderType unitTestProviderType, IEnumerable <string> methodsToTest, string tagFilters, int numberOfBrowserHosts, WebBrowserType webBrowserType, bool showTestingBrowserHost, string entryPointAssembly) { if (methodsToTest == null) { throw new ArgumentNullException("methodsToTest"); } if (unitTestProviderType == UnitTestProviderType.Undefined) { throw new ArgumentException("Must be defined", "unitTestProviderType"); } if (numberOfBrowserHosts <= 0) { throw new ArgumentOutOfRangeException("numberOfBrowserHosts", "Must be greater than 0"); } _methodsToTest = methodsToTest.ToCollection(); _tagFilters = tagFilters ?? string.Empty; UnitTestProviderType = unitTestProviderType; NumberOfBrowserHosts = numberOfBrowserHosts; WebBrowserType = webBrowserType; ShowTestingBrowserHost = showTestingBrowserHost; EntryPointAssembly = entryPointAssembly; }
public StatLightConfiguration GetStatLightConfigurationForXap(UnitTestProviderType unitTestProviderType, string xapPath, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, Collection<string> methodsToTest, string tagFilters, int numberOfBrowserHosts, bool isRemoteRun, string queryString, WebBrowserType webBrowserType, bool forceBrowserStart, bool showTestingBrowserHost) { if (queryString == null) throw new ArgumentNullException("queryString"); Func<IEnumerable<ITestFile>> filesToCopyIntoHostXap = () => new List<ITestFile>(); string runtimeVersion = null; string entryPointAssembly = string.Empty; if (isRemoteRun) { } else { AssertFileExists(xapPath); var xapReader = new XapReader(_logger); TestFileCollection testFileCollection = xapReader.LoadXapUnderTest(xapPath); runtimeVersion = XapReader.GetRuntimeVersion(xapPath); SetupUnitTestProviderType(testFileCollection, ref unitTestProviderType, ref microsoftTestingFrameworkVersion); entryPointAssembly = testFileCollection.TestAssemblyFullName; filesToCopyIntoHostXap = () => { return xapReader.LoadXapUnderTest(xapPath).FilesContainedWithinXap; }; } var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly); var serverConfig = CreateServerConfiguration( xapPath, clientConfig.UnitTestProviderType, microsoftTestingFrameworkVersion, filesToCopyIntoHostXap, DefaultDialogSmackDownElapseMilliseconds, queryString, forceBrowserStart, showTestingBrowserHost, runtimeVersion); return new StatLightConfiguration(clientConfig, serverConfig); }
public IntegrationTestClientTestRunConfiguration(UnitTestProviderType unitTestProviderType, IEnumerable <string> methodsToTest) : base(unitTestProviderType, methodsToTest, string.Empty, 1, StatLight.Core.WebBrowser.WebBrowserType.SelfHosted, string.Empty, null) { }
public IntegrationTestClientTestRunConfiguration(UnitTestProviderType unitTestProviderType) : base(unitTestProviderType, new List<string>(), string.Empty, 1, StatLight.Core.WebBrowser.WebBrowserType.SelfHosted, false, string.Empty) { }
public IntegrationTestClientTestRunConfiguration(UnitTestProviderType unitTestProviderType, IEnumerable<string> methodsToTest) : base(unitTestProviderType, methodsToTest, string.Empty, 1, StatLight.Core.WebBrowser.WebBrowserType.SelfHosted, false, string.Empty) { }
private void ShouldLoadCorrectType(string fileName, UnitTestProviderType unitTestProviderType) { var xapReadItems = new Core.WebServer.XapInspection.XapReader(new ConsoleLogger(LogChatterLevels.Full)).LoadXapUnderTest(fileName); xapReadItems.UnitTestProvider.ShouldEqual(unitTestProviderType); }
public InputOptions SetUnitTestProviderType(UnitTestProviderType unitTestProviderType) { UnitTestProviderType = unitTestProviderType; return(this); }
public TestReportCollection Run() { bool showTestingBrowserHost = _options.ShowTestingBrowserHost; bool useRemoteTestPage = _options.UseRemoteTestPage; Collection <string> methodsToTest = _options.MethodsToTest; MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion = _options.MicrosoftTestingFrameworkVersion; string tagFilters = _options.TagFilters; UnitTestProviderType unitTestProviderType = _options.UnitTestProviderType; int numberOfBrowserHosts = _options.NumberOfBrowserHosts; string queryString = _options.QueryString; WebBrowserType webBrowserType = _options.WebBrowserType; bool forceBrowserStart = _options.ForceBrowserStart; IEnumerable <string> xapPaths = _options.XapPaths; IEnumerable <string> testDlls = _options.Dlls; _options.DumpValuesForDebug(_logger); var runnerType = GetRunnerType(); _logger.Debug("RunnerType = {0}".FormatWith(runnerType)); var testReports = new TestReportCollection(); foreach (var xapPath in xapPaths) { _logger.Debug("Starting configuration for: {0}".FormatWith(xapPath)); StatLightConfiguration statLightConfiguration = _statLightConfigurationFactory .GetStatLightConfigurationForXap( unitTestProviderType, xapPath, microsoftTestingFrameworkVersion, methodsToTest, tagFilters, numberOfBrowserHosts, useRemoteTestPage, queryString, webBrowserType, forceBrowserStart, showTestingBrowserHost); var testReport = DoTheRun(runnerType, statLightConfiguration); testReports.Add(testReport); } foreach (var dllPath in testDlls) { _logger.Debug("Starting configuration for: {0}".FormatWith(dllPath)); StatLightConfiguration statLightConfiguration = _statLightConfigurationFactory .GetStatLightConfigurationForDll( unitTestProviderType, dllPath, microsoftTestingFrameworkVersion, methodsToTest, tagFilters, numberOfBrowserHosts, useRemoteTestPage, queryString, webBrowserType, forceBrowserStart, showTestingBrowserHost); var testReport = DoTheRun(runnerType, statLightConfiguration); testReports.Add(testReport); } string xmlReportOutputPath = _options.XmlReportOutputPath; bool tfsGenericReport = _options.TFSGenericReport; XmlReportType xmlReportType = XmlReportType.StatLight; if (tfsGenericReport) { xmlReportType = XmlReportType.TFS; } WriteXmlReport(testReports, xmlReportOutputPath, xmlReportType); return(testReports); }
public IntegrationTestClientTestRunConfiguration(UnitTestProviderType unitTestProviderType) : base(unitTestProviderType, new List <string>(), string.Empty, 1, StatLight.Core.WebBrowser.WebBrowserType.SelfHosted, string.Empty, null) { }
public InputOptions SetUnitTestProviderType(UnitTestProviderType unitTestProviderType) { UnitTestProviderType = unitTestProviderType; return this; }
public XapHostType MapToXapHostType(UnitTestProviderType unitTestProviderType, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, bool isPhoneRun) { Action throwNotSupportedException = () => { throw new NotSupportedException( "Cannot map to a xap host based on the following input values UnitTestProviderType={0}, MicrosoftTestingFrameworkVersion={1}" .FormatWith(unitTestProviderType, microsoftTestingFrameworkVersion)); }; if (isPhoneRun) { switch (unitTestProviderType) { case UnitTestProviderType.MSTest: if (microsoftTestingFrameworkVersion != null && microsoftTestingFrameworkVersion == MicrosoftTestingFrameworkVersion.MSTest2010May) return XapHostType.MSTest2010MayPhone; throwNotSupportedException(); break; case UnitTestProviderType.MSTestWithCustomProvider: throw new NotSupportedException("Could possibly be supported - but just not done yet"); case UnitTestProviderType.UnitDriven: throw new NotSupportedException("Could possibly be supported - but just not done yet"); case UnitTestProviderType.Undefined: default: throwNotSupportedException(); break; } } else { switch (unitTestProviderType) { case UnitTestProviderType.NUnit: case UnitTestProviderType.XUnitLight: return XapHostType.MSTest2010May; case UnitTestProviderType.MSTestWithCustomProvider: case UnitTestProviderType.MSTest: if (microsoftTestingFrameworkVersion.HasValue) { var msTestVersionXapHostStringName = microsoftTestingFrameworkVersion.Value.ToString(); if (Enum.IsDefined(typeof(XapHostType), msTestVersionXapHostStringName)) return (XapHostType)Enum.Parse(typeof(XapHostType), msTestVersionXapHostStringName); } throwNotSupportedException(); break; case UnitTestProviderType.UnitDriven: return XapHostType.UnitDriven2009December; case UnitTestProviderType.XUnit: return XapHostType.XunitContrib2011April; case UnitTestProviderType.Undefined: default: throwNotSupportedException(); break; } } return XapHostType.UnitDriven2009December; }
private static void SetupUnitTestProviderType(TestFileCollection testFileCollection, ref UnitTestProviderType unitTestProviderType, ref MicrosoftTestingFrameworkVersion?microsoftTestingFrameworkVersion) { if (unitTestProviderType == UnitTestProviderType.Undefined || microsoftTestingFrameworkVersion == null) { //TODO: Print message telling the user what the type is - and if they give it // we don't have to "reflect" on the xap to determine the test provider type. if (unitTestProviderType == UnitTestProviderType.Undefined) { unitTestProviderType = testFileCollection.UnitTestProvider; } if ( (testFileCollection.UnitTestProvider == UnitTestProviderType.MSTest || unitTestProviderType == UnitTestProviderType.MSTest || unitTestProviderType == UnitTestProviderType.MSTestWithCustomProvider) && microsoftTestingFrameworkVersion == null) { microsoftTestingFrameworkVersion = testFileCollection.MSTestVersion; } } }
private ServerTestRunConfiguration CreateServerConfiguration( string xapPath, UnitTestProviderType unitTestProviderType, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, IEnumerable<ITestFile> filesToCopyIntoHostXap, long dialogSmackDownElapseMilliseconds, string queryString, bool forceBrowserStart, bool showTestingBrowserHost) { XapHostType xapHostType = _xapHostFileLoaderFactory.MapToXapHostType(unitTestProviderType, microsoftTestingFrameworkVersion); Func<byte[]> hostXapFactory = () => { byte[] hostXap = _xapHostFileLoaderFactory.LoadXapHostFor(xapHostType); hostXap = RewriteXapWithSpecialFiles(hostXap, filesToCopyIntoHostXap); return hostXap; }; return new ServerTestRunConfiguration(hostXapFactory, dialogSmackDownElapseMilliseconds, xapPath, xapHostType, queryString, forceBrowserStart, showTestingBrowserHost); }