/// <summary> /// Create a new assembly manager, takes in the harness, provider /// reference and actual IAssembly object. /// </summary> /// <param name="runFilter">The test run filter object.</param> /// <param name="testHarness">Harness object.</param> /// <param name="provider">The unit test metadata provider.</param> /// <param name="testAssembly">The test assembly metadata object.</param> public AssemblyManager(TestRunFilter runFilter, UnitTestHarness testHarness, IUnitTestProvider provider, IAssembly testAssembly) : base(testHarness, provider) { _filter = runFilter; _assembly = testAssembly; _testClasses = new CompositeWorkItem(); ClassInstances = new TestClassInstanceDictionary(); }
/// <summary> /// Initializes dispatcher-stack attaching method container work item. /// </summary> /// <param name="testHarness">Test harness.</param> /// <param name="instance">Test instance.</param> /// <param name="method">Method reflection object.</param> /// <param name="testMethod">Test method metadata.</param> /// <param name="granularity">Granularity of test.</param> public UnitTestMethodContainer(UnitTestHarness testHarness, object instance, MethodInfo method, ITestMethod testMethod, TestGranularity granularity) : base(instance, method, testMethod) { _granularity = granularity; _harness = testHarness as UnitTestHarness; _testMethod = testMethod; }
public void Run(UnitTestSettings settings) { // Avoid having the Run method called twice if (_harness != null) { return; } _harness = settings.TestHarness; if (_harness == null) { throw new InvalidOperationException(Properties.UnitTestMessage.UnitTestSystem_Run_NoTestHarnessInSettings); } if (settings.TestService == null && !settings.TestServiceSetterCalled) { SetTestService(settings); } _harness.Settings = settings; _harness.TestHarnessCompleted += (sender, args) => OnTestHarnessCompleted(args); if (settings.StartRunImmediately) { _harness.Run(); } }
/// <summary> /// A container type that handles an entire test class throughout the /// test run. /// </summary> /// <param name="filter">Test run filter object.</param> /// <param name="testHarness">The unit test harness.</param> /// <param name="testClass">The test class metadata interface.</param> /// <param name="instance">The object instance.</param> /// <param name="provider">The unit test provider.</param> public TestClassManager(TestRunFilter filter, UnitTestHarness testHarness, ITestClass testClass, object instance, IUnitTestProvider provider) : base(testHarness, provider) { _filter = filter; _testClass = testClass; _testExecutionQueue = new CompositeWorkItem(); _instance = instance; }
/// <summary> /// Constructor for a test method manager, which handles executing a single test method /// for a unit test provider. /// </summary> /// <param name="testHarness">The unit test harness object.</param> /// <param name="testClass">The test class metadata object.</param> /// <param name="testMethod">The test method metadata object.</param> /// <param name="instance">The test class instance.</param> /// <param name="provider">The unit test provider.</param> public TestMethodManager(UnitTestHarness testHarness, ITestClass testClass, ITestMethod testMethod, object instance, IUnitTestProvider provider) : base(testHarness, provider) { _testClass = testClass; _testMethod = testMethod; _instance = instance; }
public BaseTestAssembly(IUnitTestProvider provider, UnitTestHarness testHarness, Assembly assembly) { this.provider = provider; this.testHarness = testHarness; this.assembly = assembly; this.init = new LazyAssemblyMethodInfo(this.assembly, typeof(AssemblyInitializeAttribute)); this.cleanup = new LazyAssemblyMethodInfo(this.assembly, typeof(AssemblyCleanupAttribute)); }
/// <summary> /// Creates a new unit test assembly wrapper. /// </summary> /// <param name="provider">Unit test metadata provider.</param> /// <param name="unitTestHarness">A reference to the unit test harness.</param> /// <param name="assembly">Assembly reflection object.</param> public UnitTestFrameworkAssembly(IUnitTestProvider provider, UnitTestHarness unitTestHarness, Assembly assembly) { _provider = provider; _harness = unitTestHarness; _assembly = assembly; _init = new LazyAssemblyMethodInfo(_assembly, ProviderAttributes.AssemblyInitialize); _cleanup = new LazyAssemblyMethodInfo(_assembly, ProviderAttributes.AssemblyCleanup); }
public UnitTestFrameworkAssembly(IUnitTestProvider provider, UnitTestHarness unitTestHarness, Assembly assembly) { this.provider = provider; harness = unitTestHarness; this.assembly = assembly; lazyMethodInfo = new LazyAssemblyMethodInfo(this.assembly, ProviderAttributes.AssemblyInitialize); cleanup = new LazyAssemblyMethodInfo(this.assembly, ProviderAttributes.AssemblyCleanup); }
/// <summary> /// Creates a new unit test assembly wrapper. /// </summary> /// <param name="provider">Unit test metadata provider.</param> /// <param name="unitTestHarness">A reference to the unit test harness.</param> /// <param name="assembly">Assembly reflection object.</param> public BddTestAssembly(IUnitTestProvider provider, UnitTestHarness unitTestHarness, Assembly assembly) { _provider = provider; _harness = unitTestHarness; _assembly = assembly; _init = new LazyAssemblyMethodInfo(_assembly, typeof(AssemblyInitializeAttribute)); _cleanup = new LazyAssemblyMethodInfo(_assembly, typeof(AssemblyCleanupAttribute)); }
/// <summary>Constructor.</summary> public UnitTestMonitor(UnitTestSettings settings) { // Setup initial conditions. if (settings == null) throw new ArgumentNullException("settings"); harness = settings.TestHarness; // Wire up events. WireEvents(true); }
/// <summary> /// Initializes a new instance of the DataManager type. /// </summary> /// <param name="harness">The unit test harness instance.</param> private DataManager(UnitTestHarness harness) { _d = new TestRunData(harness); _h = harness; _assemblyData = new Dictionary<IAssembly, TestAssemblyData>(2); _classData = new Dictionary<ITestClass, TestClassData>(50); _methodData = new Dictionary<ITestMethod, TestMethodData>(300); }
/// <summary> /// Initializes a new intance of the UnitTestHarnessEvents helper. /// </summary> /// <param name="harness">The harness reference.</param> public UnitTestHarnessEvents(UnitTestHarness harness) { if (harness == null) { throw new ArgumentNullException("harness"); } _harness = harness; }
/// <summary> /// Initializes a new unit test work item container. /// </summary> /// <param name="testHarness">The unit test harness.</param> /// <param name="unitTestProvider">The unit test metadata provider.</param> protected UnitTestCompositeWorkItem(UnitTestHarness testHarness, IUnitTestProvider unitTestProvider) : base() { _provider = unitTestProvider; TestHarness = testHarness; if (TestHarness == null) { throw new InvalidOperationException(Properties.UnitTestMessage.UnitTestCompositeWorkItem_ctor_NoTestHarness); } }
public IAssembly GetUnitTestAssembly(UnitTestHarness testHarness, Assembly assemblyReference) { if (assemblyCache.ContainsKey(assemblyReference)) { return assemblyCache[assemblyReference]; } assemblyCache[assemblyReference] = new UnitTestFrameworkAssembly(this, testHarness, assemblyReference); return assemblyCache[assemblyReference]; }
/// <summary> /// Records a harness state for the unit test harness. /// </summary> /// <param name="harness">The unit test harness.</param> /// <param name="name">The harness name.</param> /// <param name="stage">The test stage.</param> public void UnitTestHarnessStage(UnitTestHarness harness, string name, TestStage stage) { LogMessage m = Create(LogMessageType.TestExecution, name); MarkUnitTestMessage(m); DecorateNameProperty(m, name); DecorateTestGranularity(m, TestGranularity.Harness); m[UnitTestLogDecorator.UnitTestHarness] = harness; DecorateTestStage(m, stage); Enqueue(m); }
public TestAssembly( IUnitTestProvider provider, UnitTestHarness testHarness, Feature feature) { _provider = provider; _testHarness = testHarness; _feature = feature; _classes = new List<ITestClass>(); _classes.Add(new TestClass(this, _feature)); }
/// <summary> /// Initialize a new writer class. /// </summary> /// <param name="harness">The test harness instance.</param> /// <param name="messageFactory"> /// The factory to use when creating new messages. /// </param> public LogMessageWriter(UnitTestHarness harness, LogMessageFactory messageFactory) { if (harness == null) { throw new ArgumentNullException("harness"); } else if (messageFactory == null) { throw new ArgumentNullException("messageFactory"); } _testHarness = harness; _factory = messageFactory; }
/// <summary> /// Initializes a new instance of the test run results. /// </summary> /// <param name="unitTestHarness">The unit test harness.</param> public TestRunData(UnitTestHarness unitTestHarness) { Passed = true; _assemblies = new ObservableCollection<TestAssemblyData>(); _harness = unitTestHarness; _information = new TestApplicationInformation(); _harness.TestAssemblyStarting += (x, xe) => IsRunning = true; _harness.TestAssemblyCompleted += (x, xe) => { IsRunning = false; NotifyPropertyChanged("PassedAndComplete"); }; _harness.IsDispatcherRunningChanged += (x, xe) => NotifyPropertyChanged("IsDispatcherRunning"); }
public static void RunTests(Application app) { UnitTestSettings settings = UnitTestSystem.CreateDefaultSettings(); settings.StartRunImmediately = SuppressTagExpressionEditor(); settings.ShowTagExpressionEditor = !SuppressTagExpressionEditor(); settings.TestHarness = new AgTestHarness(); TestHarness = (UnitTestHarness)settings.TestHarness; settings.TestAssemblies.Clear(); settings.TestAssemblies.Add(Assembly.GetCallingAssembly()); if(IsGUI()) { string categories = (string)HtmlPage.Window.Eval("window.external.GetIgnoreCategories();"); IgnoredCategories.AddRange(categories.Split(';')); settings.LogProviders.Clear(); settings.LogProviders.Add(new SilverlightTestGUILog()); TestHarness.TestHarnessCompleted += TestHarnessCompleted; } else { IgnoredCategories.Add("TODO"); } UnitTestProviders.Providers.Add(new BaseUnitTestProvider()); app.RootVisual = CreateRootVisual(settings); }
private void Application_Startup(object sender, StartupEventArgs e) { var harness = new UnitTestHarness(); var settings = new UnitTestSettings(); settings.TestHarness = harness; harness.Settings = settings; harness.Initialize(); harness.TestRunStarting += (senderx, ex) => { var provider = new TestProvider(); var filter = new TagTestRunFilter(settings, harness, settings.TagExpression); var features = FeatureFactory.GetFeatures(typeof(App).Assembly); foreach (var feature in features) { provider.RegisterFeature(feature); var ass = provider.GetUnitTestAssembly(harness, feature.Assembly); harness.EnqueueTestAssembly(ass, filter); } }; this.RootVisual = UnitTestSystem.CreateTestPage(settings); }
public AgTestRunFilter(UnitTestSettings settings, UnitTestHarness harness) : base(settings, harness) { }
public void WriteLogFile(UnitTestHarness harness) { _writer.Finished = DateTime.Now; harness.WriteLogFile(TestResultsFileName, _writer.GetXmlAsString()); }
public RiaTestRunFilter(UnitTestSettings settings, UnitTestHarness harness, Func<ITestMethod, bool> includeTest) : base(settings, harness) { _includeTest = includeTest; }
/// <summary> /// Initializes a new test run filter with the tag expression. /// </summary> /// <param name="settings">Unit test settings.</param> /// <param name="harness">Unit test harness.</param> /// <param name="tagExpression">The tag expression to use.</param> public TagTestRunFilter(UnitTestSettings settings, UnitTestHarness harness, string tagExpression) : base(settings, harness) { SetTagExpression(tagExpression); }
/// <summary> /// Initializes a new instance of the TestAssemblyStartingEventArgs /// type. /// </summary> /// <param name="assembly">The assembly metadata.</param> /// <param name="harness">The unit test harness instance.</param> public TestAssemblyStartingEventArgs(IAssembly assembly, UnitTestHarness harness) : base(harness) { Assembly = assembly; }
/// <summary> /// Initializes a new instance of the TestAssemblyCompletedEventArgs /// type. /// </summary> /// <param name="assembly">The assembly metadata.</param> /// <param name="harness">The test harness instance.</param> public TestAssemblyCompletedEventArgs(IAssembly assembly, UnitTestHarness harness) : base(harness) { Assembly = assembly; }
/// <summary> /// Initializes a new instance of the TestMethodStartingEventArgs type. /// </summary> /// <param name="testMethod">The test method metadata.</param> /// <param name="testClass">The test class metadata.</param> /// <param name="harness">The test harness instance.</param> public TestMethodStartingEventArgs(ITestMethod testMethod, ITestClass testClass, UnitTestHarness harness) : base(harness) { TestMethod = testMethod; TestClass = testClass; }
/// <summary> /// Initializes a new unit test logic factory. /// </summary> /// <param name="harness">The unit test harness reference.</param> public UnitTestLogicFactory(UnitTestHarness harness) { _harness = harness; }
/// <summary> /// Initializes a new instance of the TestClassStartingEventArgs type. /// </summary> /// <param name="testClass">The test class metadata.</param> /// <param name="harness">The unit test harness reference.</param> public TestClassStartingEventArgs(ITestClass testClass, UnitTestHarness harness) : base(harness) { TestClass = testClass; }
/// <summary> /// Initializes the unit test log message writer helper. /// </summary> /// <param name="harness">The test harness reference.</param> public UnitTestLogMessageWriter(UnitTestHarness harness) : base(harness) { }
/// <summary> /// Initializes a new instance of the DataManager. /// </summary> /// <param name="harness">The unit test harness instance.</param> /// <returns>Returns a new instance of a DataManager class.</returns> public static DataManager Create(UnitTestHarness harness) { return new DataManager(harness); }
/// <summary> /// Initializes the test harness. /// </summary> /// <param name="settings">The test harness settings.</param> public void Initialize(UnitTestSettings settings) { UnitTestHarness uth = settings.TestHarness as UnitTestHarness; if (uth != null) { // Attach to store the log file uth.Publishing += (o, e) => WriteLogFile(uth); // Look for a unique test run ID if (uth.TestService != null) { string runId = uth.TestService.UniqueTestRunIdentifier; if (!string.IsNullOrEmpty(runId)) { TestRunId = runId; } } } string filename; if (settings.Parameters.TryGetValue("log", out filename)) { TestResultsFileName = filename; } // Read pre-defined optional settings and environment variables List <string> prefix = new List <string>(); string initialPrefix; if (settings.Parameters.TryGetValue("testRunNamePrefix", out initialPrefix)) { prefix.Add(initialPrefix); } string userName; if (settings.Parameters.TryGetValue("userName", out userName)) { prefix.Add(userName); UserName = userName; } string computerName; if (settings.Parameters.TryGetValue("computerName", out computerName)) { prefix.Add(computerName); ComputerName = computerName; } for (int i = 0; i < prefix.Count; ++i) { if (TestRunNamePrefix.Length > 0) { TestRunNamePrefix += "_"; } TestRunNamePrefix += prefix[i]; } }
/// <summary> /// Initialize a new writer class, using the default LogMessageFactory /// to create new messages. /// </summary> /// <param name="harness">The test harness instance.</param> public LogMessageWriter(UnitTestHarness harness) : this(harness, new LogMessageFactory()) { }
/// <summary> /// Initializes a new instance of the TestClassCompletedEventArgs /// class. /// </summary> /// <param name="testClass">Test class metadata.</param> /// <param name="harness">The harness instance.</param> public TestClassCompletedEventArgs(ITestClass testClass, UnitTestHarness harness) : base(harness) { TestClass = testClass; }
/// <summary> /// VSTT unit test provider constructor; takes an assembly reference to /// perform reflection on to retrieve all test class types. In this /// implementation of an engine for the VSTT metadata, only a single /// test Assembly can be utilized at a time for simplicity. /// </summary> /// <param name="testHarness">The unit test harness.</param> /// <param name="assemblyReference">Assembly reflection object.</param> /// <returns>Returns the assembly metadata interface.</returns> #if March2010 || April2010 || May2010 || May2010 || July2009 || October2009 || November2009 public IAssembly GetUnitTestAssembly(ITestHarness testHarness, Assembly assemblyReference)
/// <summary> /// Initializes a new instance of the UnitTestHarnessEventArgs class. /// </summary> /// <param name="harness">The test harness.</param> public UnitTestHarnessEventArgs(UnitTestHarness harness) : base() { UnitTestHarness = harness; }
/// <summary> /// Initializes a new test run filter using an existing settings file. /// </summary> /// <param name="settings">A unit test settings instance.</param> /// <param name="harness">The unit test harness.</param> public TestRunFilter(UnitTestSettings settings, UnitTestHarness harness) { TestRunName = DefaultTestRunName; _settings = settings; UnitTestHarness = harness; }
/// <summary> /// Initializes a new instance of the TestMethodCompletedEventArgs /// type. /// </summary> /// <param name="result">The result instance.</param> /// <param name="harness">The unit test harness.</param> public TestMethodCompletedEventArgs(ScenarioResult result, UnitTestHarness harness) : base(harness) { Result = result; }