Пример #1
0
 /// <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();
 }
Пример #2
0
 /// <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;
 }
Пример #3
0
        /// <summary>
        /// Enqueues a test assembly.
        /// </summary>
        /// <param name="testAssembly">The test assembly metadata.</param>
        /// <param name="runFilter">The run filter settings for the test assembly's run.</param>
        public void EnqueueTestAssembly(IAssembly testAssembly, TestRunFilter runFilter)
        {
            AssemblyManager assemblyManager = LogicFactory.CreateAssemblyManager(testAssembly.Provider, runFilter, testAssembly);

            _harnessTasks.Enqueue(assemblyManager);
            _knownTestMethods = CalculateTotalMethods(assemblyManager, testAssembly, runFilter);
            ++_validTestAssemblies;
        }
Пример #4
0
        /// <summary>
        /// Enqueues a message containing a test run filter.
        /// </summary>
        /// <param name="filter">The test run filter.</param>
        public void TestRunFilterSelected(TestRunFilter filter)
        {
            string     message = filter.TestRunName;
            LogMessage m       = Create(LogMessageType.TestInfrastructure, message);

            MarkUnitTestMessage(m);
            m[UnitTestLogDecorator.TestRunFilter] = filter;
            Enqueue(m);
        }
Пример #5
0
        /// <summary>
        /// Enqueue a test assembly from a simple Assembly reference.
        /// </summary>
        /// <param name="assembly">The test assembly.</param>
        /// <param name="runFilter">The run filter settings for the test assembly's run.</param>
        public void EnqueueTestAssembly(Assembly assembly, TestRunFilter runFilter)
        {
            IAssembly testAssembly = UnitTestProviders.GetAssemblyWrapper(this, assembly);

            if (testAssembly != null)
            {
                EnqueueTestAssembly(testAssembly, runFilter);
            }
        }
Пример #6
0
        /// <summary>
        /// Determine what test assemblies need to be executed.  Enqueue tasks
        /// for the unit test assembly providers to run the tests.
        /// </summary>
        private void PrepareTestAssemblyTasks()
        {
            // Regular unit test run
            UnitTestSettings settings = Settings as UnitTestSettings;
            TestRunFilter    filter   = CreateTestRunFilter(settings);

            // Log the filter information
            LogWriter.TestRunFilterSelected(filter);

            // Add the test assemblies
            foreach (Assembly assembly in Settings.TestAssemblies)
            {
                EnqueueTestAssembly(assembly, filter);
            }
            if (_validTestAssemblies > 0)
            {
                LogWriter.UnitTestHarnessStage(this, HarnessName, TestStage.Starting);
            }
            else
            {
                LogWriter.Warning(Properties.UnitTestMessage.UnitTestHarness_TestAssembliesNotActionable);
            }
        }
Пример #7
0
        /// <summary>
        /// Calculates the number of methods for a run.
        /// </summary>
        /// <param name="assemblyManager">The assembly manager.</param>
        /// <param name="assembly">The test assembly.</param>
        /// <param name="filter">The test run filter.</param>
        /// <returns>Returns the number of known methods returned.</returns>
        private static int CalculateTotalMethods(AssemblyManager assemblyManager, IAssembly assembly, TestRunFilter filter)
        {
            int total             = 0;
            List <ITestClass> cls = filter.GetTestClasses(assembly, assemblyManager.ClassInstances);

            foreach (ITestClass test in cls)
            {
                object instance = assemblyManager.ClassInstances.GetInstance(test.Type);
                total += filter.GetTestMethods(test, instance).Count;
            }
            return(total);
        }
Пример #8
0
        /// <summary>
        /// Creates the test run filter for the initial run.
        /// </summary>
        /// <param name="settings">The unit test settings.</param>
        /// <returns>Returns a new TestRunFilter instance.</returns>
        protected virtual TestRunFilter CreateTestRunFilter(UnitTestSettings settings)
        {
            TestRunFilter subfilter = String.IsNullOrEmpty(settings.TagExpression) ? new TestRunFilter(settings, this) : new TagTestRunFilter(settings, this, settings.TagExpression);

            return(new RuntimeVersionTestRunFilter(settings, this, subfilter));
        }
Пример #9
0
 public RuntimeVersionTestRunFilter(UnitTestSettings settings, UnitTestHarness harness, TestRunFilter subfilter) : base(settings, harness)
 {
     this.subfilter       = subfilter;
     this.runtime_version = settings.RuntimeVersion;
 }
Пример #10
0
        /// <summary>
        /// The run filter has been selected.
        /// </summary>
        /// <param name="logMessage">The log message object.</param>
        private void TestRunFilterSelected(LogMessage logMessage)
        {
            TestRunFilter filter = (TestRunFilter)logMessage[UnitTestLogDecorator.TestRunFilter];

            TestListName = filter.TestRunName;
        }
Пример #11
0
 /// <summary>
 /// Creates a new TestClassManager.
 /// </summary>
 /// <param name="provider">The unit test provider.</param>
 /// <param name="filter">The run filter.</param>
 /// <param name="testClass">The test class metadata.</param>
 /// <param name="instance">The test class instance.</param>
 /// <returns>Returns a new TestClassManager.</returns>
 public TestClassManager CreateTestClassManager(IUnitTestProvider provider, TestRunFilter filter, ITestClass testClass, object instance)
 {
     return(new TestClassManager(filter, _harness, testClass, instance, provider));
 }
Пример #12
0
 /// <summary>
 /// Creates a new AssemblyManager.
 /// </summary>
 /// <param name="provider">The unit test provider.</param>
 /// <param name="filter">The run filter.</param>
 /// <param name="assembly">The unit test assembly metadata object.</param>
 /// <returns>Returns a new AssemblyManager.</returns>
 public AssemblyManager CreateAssemblyManager(IUnitTestProvider provider, TestRunFilter filter, IAssembly assembly)
 {
     return(new AssemblyManager(filter, _harness, provider, assembly));
 }
Пример #13
0
 /// <summary>
 /// Creates a new TestClassManager.
 /// </summary>
 /// <param name="provider">The unit test provider.</param>
 /// <param name="filter">The run filter.</param>
 /// <param name="testClass">The test class metadata.</param>
 /// <param name="instance">The test class instance.</param>
 /// <returns>Returns a new TestClassManager.</returns>
 public TestClassManager CreateTestClassManager(IUnitTestProvider provider, TestRunFilter filter, ITestClass testClass, object instance)
 {
     return new TestClassManager(filter, _harness, testClass, instance, provider);
 }
Пример #14
0
 /// <summary>
 /// Creates a new AssemblyManager.
 /// </summary>
 /// <param name="provider">The unit test provider.</param>
 /// <param name="filter">The run filter.</param>
 /// <param name="assembly">The unit test assembly metadata object.</param>
 /// <returns>Returns a new AssemblyManager.</returns>
 public AssemblyManager CreateAssemblyManager(IUnitTestProvider provider, TestRunFilter filter, IAssembly assembly)
 {
     return new AssemblyManager(filter, _harness, provider, assembly);
 }