public ITest Build(string assemblyName, IDictionary options) { TestSuite testAssembly = null; try { var assembly = AssemblyHelper.Load(assemblyName); testAssembly = Build(assembly, assemblyName, options); } catch (Exception ex) { testAssembly = new TestAssembly(assemblyName); testAssembly.RunState = RunState.NotRunnable; testAssembly.Properties.Set(PropertyNames.SkipReason, ex.Message); } return testAssembly; }
private TestSuite Build(Assembly assembly, string assemblyPath, IDictionary options) { TestSuite testAssembly = null; try { IList fixtureNames = options[PackageSettings.LOAD] as IList; var fixtures = GetFixtures(assembly, fixtureNames); testAssembly = BuildTestAssembly(assembly, assemblyPath, fixtures); } catch (Exception ex) { Debug.LogException(ex); testAssembly = new TestAssembly(assemblyPath); testAssembly.RunState = RunState.NotRunnable; testAssembly.Properties.Set(PropertyNames.SkipReason, ex.Message); } return testAssembly; }
private TestSuite BuildTestAssembly(string assemblyName, IList fixtures) { TestSuite testSuite = new TestAssembly(assembly, assemblyName); foreach (Test fixture in fixtures) { testSuite.Add(fixture); } if (fixtures.Count == 0) { testSuite.RunState = RunState.NotRunnable; testSuite.Properties.Set(PropertyNames.SkipReason, "Has no TestFixtures"); } testSuite.ApplyCommonAttributes(assembly); testSuite.Properties.Set(PropertyNames.ProcessID, Process.GetCurrentProcess().Id); testSuite.Properties.Set(PropertyNames.AppDomain, AppDomain.CurrentDomain.FriendlyName); testSuite.Sort(); return(testSuite); }
private TestSuite BuildTestAssembly(string assemblyName, IList fixtures) { TestSuite testAssembly = new TestAssembly(this.assembly, assemblyName); testAssembly.Seed = Randomizer.InitialSeed; //NamespaceTreeBuilder treeBuilder = // new NamespaceTreeBuilder(testAssembly); //treeBuilder.Add(fixtures); //testAssembly = treeBuilder.RootSuite; foreach (Test fixture in fixtures) { testAssembly.Add(fixture); } if (fixtures.Count == 0) { testAssembly.RunState = RunState.NotRunnable; testAssembly.Properties.Set(PropertyNames.SkipReason, "Has no TestFixtures"); } #if PORTABLE testAssembly.ApplyAttributesToTest(assembly.AsCustomAttributeProvider()); #else testAssembly.ApplyAttributesToTest(assembly); #endif #if !SILVERLIGHT && !PORTABLE testAssembly.Properties.Set(PropertyNames.ProcessID, System.Diagnostics.Process.GetCurrentProcess().Id); #endif #if !PORTABLE testAssembly.Properties.Set(PropertyNames.AppDomain, AppDomain.CurrentDomain.FriendlyName); #endif // TODO: Make this an option? Add Option to sort assemblies as well? testAssembly.Sort(); return(testAssembly); }
private TestSuite BuildTestAssembly(Assembly assembly, string assemblyName, IList<Test> fixtures) { TestSuite testAssembly = new TestAssembly(assembly, assemblyName); if (fixtures.Count == 0) { testAssembly.RunState = RunState.NotRunnable; testAssembly.Properties.Set(PropertyNames.SkipReason, "Has no TestFixtures"); } else { NamespaceTreeBuilder treeBuilder = new NamespaceTreeBuilder(testAssembly); treeBuilder.Add(fixtures); testAssembly = treeBuilder.RootSuite; } testAssembly.ApplyAttributesToTest(assembly); #if !PORTABLE #if !SILVERLIGHT testAssembly.Properties.Set(PropertyNames.ProcessID, System.Diagnostics.Process.GetCurrentProcess().Id); #endif testAssembly.Properties.Set(PropertyNames.AppDomain, AppDomain.CurrentDomain.FriendlyName); #endif // TODO: Make this an option? Add Option to sort assemblies as well? testAssembly.Sort(); return testAssembly; }
private TestSuite Build(Assembly assembly, string assemblyPath, IDictionary<string, object> options) { TestSuite testAssembly = null; try { if (options.ContainsKey(PackageSettings.DefaultTestNamePattern)) TestNameGenerator.DefaultTestNamePattern = options[PackageSettings.DefaultTestNamePattern] as string; if (options.ContainsKey(PackageSettings.TestParameters)) { string parameters = options[PackageSettings.TestParameters] as string; if (!string.IsNullOrEmpty(parameters)) foreach (string param in parameters.Split(new[] { ';' })) { int eq = param.IndexOf("="); if (eq > 0 && eq < param.Length - 1) { var name = param.Substring(0, eq); var val = param.Substring(eq + 1); TestContext.Parameters.Add(name, val); } } } IList fixtureNames = null; if (options.ContainsKey (PackageSettings.LOAD)) fixtureNames = options[PackageSettings.LOAD] as IList; var fixtures = GetFixtures(assembly, fixtureNames); testAssembly = BuildTestAssembly(assembly, assemblyPath, fixtures); } catch (Exception ex) { testAssembly = new TestAssembly(assemblyPath); testAssembly.RunState = RunState.NotRunnable; testAssembly.Properties.Set(PropertyNames.SkipReason, ex.Message); } return testAssembly; }
/// <summary> /// Build a suite of tests given the filename of an assembly /// </summary> /// <param name="assemblyName">The filename of the assembly from which tests are to be built</param> /// <param name="options">A dictionary of options to use in building the suite</param> /// <returns> /// A TestSuite containing the tests found in the assembly /// </returns> public ITest Build(string assemblyName, IDictionary<string, object> options) { #if PORTABLE log.Debug("Loading {0}", assemblyName); #else log.Debug("Loading {0} in AppDomain {1}", assemblyName, AppDomain.CurrentDomain.FriendlyName); #endif TestSuite testAssembly = null; try { var assembly = AssemblyHelper.Load(assemblyName); testAssembly = Build(assembly, assemblyName, options); } catch (Exception ex) { testAssembly = new TestAssembly(assemblyName); testAssembly.RunState = RunState.NotRunnable; testAssembly.Properties.Set(PropertyNames.SkipReason, ex.Message); } return testAssembly; }
private TestSuite BuildTestAssembly(string assemblyName, IList fixtures) { TestSuite testAssembly = new TestAssembly(this.assembly, assemblyName); testAssembly.Seed = Randomizer.InitialSeed; //NamespaceTreeBuilder treeBuilder = // new NamespaceTreeBuilder(testAssembly); //treeBuilder.Add(fixtures); //testAssembly = treeBuilder.RootSuite; foreach (Test fixture in fixtures) testAssembly.Add(fixture); if (fixtures.Count == 0) { testAssembly.RunState = RunState.NotRunnable; testAssembly.Properties.Set(PropertyNames.SkipReason, "Has no TestFixtures"); } #if PORTABLE testAssembly.ApplyAttributesToTest(assembly.AsCustomAttributeProvider()); #else testAssembly.ApplyAttributesToTest(assembly); #endif #if !SILVERLIGHT && !PORTABLE testAssembly.Properties.Set(PropertyNames.ProcessID, System.Diagnostics.Process.GetCurrentProcess().Id); #endif #if !PORTABLE testAssembly.Properties.Set(PropertyNames.AppDomain, AppDomain.CurrentDomain.FriendlyName); #endif // TODO: Make this an option? Add Option to sort assemblies as well? testAssembly.Sort(); return testAssembly; }
/// <summary> /// Copy-constructor style to create a filtered copy of the test assemblies /// test cases /// </summary> /// <param name="assembly"></param> /// <param name="filter"></param> public TestAssembly(TestAssembly assembly, ITestFilter filter) : base(assembly as TestSuite, filter) { this.Name = assembly.Name; this.Assembly = assembly.Assembly; }
/// <summary> /// Build a suite of tests given the filename of an assembly /// </summary> /// <param name="assemblyName">The filename of the assembly from which tests are to be built</param> /// <param name="options">A dictionary of options to use in building the suite</param> /// <returns> /// A TestSuite containing the tests found in the assembly /// </returns> public ITest Build(string assemblyName, IDictionary options) { log.Debug("Loading {0} in AppDomain {1}", assemblyName, AppDomain.CurrentDomain.FriendlyName); TestSuite testAssembly = new TestAssembly(assemblyName); try { this.assembly = Load(assemblyName); IList fixtureNames = options[DriverSettings.LOAD] as IList; IList fixtures = GetFixtures(assembly, fixtureNames); testAssembly = BuildTestAssembly(assemblyName, fixtures); } catch(Exception ex) { testAssembly.RunState = RunState.NotRunnable; testAssembly.Properties.Set(PropertyNames.SkipReason, ex.Message); } return testAssembly; }
private TestSuite Build(Assembly assembly, string assemblyPath, IDictionary<string, object> options) { TestSuite testAssembly = null; try { if (options.ContainsKey(FrameworkPackageSettings.DefaultTestNamePattern)) TestNameGenerator.DefaultTestNamePattern = options[FrameworkPackageSettings.DefaultTestNamePattern] as string; if (options.ContainsKey(FrameworkPackageSettings.TestParametersDictionary)) { var testParametersDictionary = options[FrameworkPackageSettings.TestParametersDictionary] as IDictionary<string, string>; if (testParametersDictionary != null) { foreach (var parameter in testParametersDictionary) TestContext.Parameters.Add(parameter.Key, parameter.Value); } } else { // This cannot be changed without breaking backwards compatibility with old runners. // Deserializes the way old runners understand. if (options.ContainsKey(FrameworkPackageSettings.TestParameters)) { string parameters = options[FrameworkPackageSettings.TestParameters] as string; if (!string.IsNullOrEmpty(parameters)) foreach (string param in parameters.Split(new[] { ';' })) { int eq = param.IndexOf("="); if (eq > 0 && eq < param.Length - 1) { var name = param.Substring(0, eq); var val = param.Substring(eq + 1); TestContext.Parameters.Add(name, val); } } } } IList fixtureNames = null; if (options.ContainsKey(FrameworkPackageSettings.LOAD)) fixtureNames = options[FrameworkPackageSettings.LOAD] as IList; var fixtures = GetFixtures(assembly, fixtureNames); testAssembly = BuildTestAssembly(assembly, assemblyPath, fixtures); } catch (Exception ex) { testAssembly = new TestAssembly(assemblyPath); testAssembly.RunState = RunState.NotRunnable; testAssembly.Properties.Set(PropertyNames.SkipReason, ExceptionHelper.BuildFriendlyMessage(ex)); } return testAssembly; }
private TestSuite BuildTestAssembly(string assemblyName, IList fixtures) { TestSuite testAssembly = new TestAssembly(this.assembly, assemblyName); testAssembly.Seed = Randomizer.InitialSeed; //NamespaceTreeBuilder treeBuilder = // new NamespaceTreeBuilder(testAssembly); //treeBuilder.Add(fixtures); //testAssembly = treeBuilder.RootSuite; foreach (Test fixture in fixtures) testAssembly.Add(fixture); if (fixtures.Count == 0) { testAssembly.RunState = RunState.NotRunnable; testAssembly.Properties.Set(PropertyNames.SkipReason, "Has no TestFixtures"); } testAssembly.ApplyAttributesToTest(assembly); testAssembly.Properties.Set(PropertyNames.AppDomain, AppDomain.CurrentDomain.FriendlyName); // TODO: Make this an option? Add Option to sort assemblies as well? testAssembly.Sort(); return testAssembly; }