Exemplo n.º 1
0
 /// <summary>
 /// Gets the included test items for the given module and suite
 /// </summary>
 /// <param name="module">The test module data</param>
 /// <param name="suite">The test suite</param>
 /// <param name="logWriter">optional log writer in case something goes wrong</param>
 /// <returns>The included test items without the excluded items</returns>
 public static IEnumerable<TestItemData> GetIncludedVariations(TestModuleData module, TestSuite suite, ITestLogWriter logWriter)
 {
     ExceptionUtilities.CheckArgumentNotNull(suite, "suite");
     var included = suite.Items.Where(i => i.IsIncluded).Select(i => i.Name);
     var excluded = suite.Items.Where(i => !i.IsIncluded).Select(i => i.Name);
     return GetIncludedVariations(module, included, excluded, logWriter);
 }
        /// <summary>
        /// Safely disposes the test log writer
        /// </summary>
        /// <param name="testLogWriter">The test log writer to dispose</param>
        public void Terminate(ITestLogWriter testLogWriter)
        {
            List<TextWriter> textWriters = this.compositeToTextWritersLookup[testLogWriter as CompositeTestLogWriter];

            foreach (TextWriter writer in textWriters)
            {
                writer.Dispose();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Safely disposes the test log writer
        /// </summary>
        /// <param name="testLogWriter">The test log writer to dispose</param>
        public void Terminate(ITestLogWriter testLogWriter)
        {
            List <TextWriter> textWriters = this.compositeToTextWritersLookup[testLogWriter as CompositeTestLogWriter];

            foreach (TextWriter writer in textWriters)
            {
                writer.Dispose();
            }
        }
        /// <summary>
        /// Runs the specified module.
        /// </summary>
        /// <param name="testModuleData">Data about the test module to run.</param>
        /// <param name="logWriter">The log writer.</param>
        /// <param name="variationsToRun">The variations to run.</param>
        /// <param name="parameters">The parameters.</param>
        public void Run(TestModuleData testModuleData, ITestLogWriter logWriter, IEnumerable <TestItemData> variationsToRun, IDictionary <string, string> parameters)
        {
            ExceptionUtilities.CheckArgumentNotNull(testModuleData, "testModuleData");
            ExceptionUtilities.CheckArgumentNotNull(logWriter, "logWriter");

            if (parameters == null)
            {
                parameters = new Dictionary <string, string>();
            }

            var testModule = (TestModule)Activator.CreateInstance(testModuleData.TestItemType);

            testModule.ExplorationSeed = testModuleData.ExplorationSeed;
            testModule.ExplorationKind = testModuleData.ExplorationKind;

            foreach (var param in parameters)
            {
                testModule.TestParameters[param.Key] = param.Value;
            }

            if (variationsToRun == null)
            {
                variationsToRun = testModuleData.GetAllChildrenRecursive().Where(c => c.IsVariation);
            }

            lock (this.lockObject)
            {
                var logger = new TestLogWriterLogger(logWriter);
                logger.OnWarning += this.OnWarning;
                testModule.Log    = logger;

                this.executionThreadAborted = false;
                this.runCompleted           = false;
                this.currentLogWriter       = logWriter;
                this.scheduledVariations    = variationsToRun.Distinct().ToDictionary <TestItemData, TestItemData>(iteration => iteration);
                this.completedItems.Clear();
                this.statisticsByPriority.Clear();
                this.globalStatistics = new RunStatistics();
                this.currentLogWriter.BeginTestSuite();
                this.executionThread = new Thread(this.ExecutionThreadStart)
                {
                    IsBackground = true,
                };

                this.executionThread.Start();
                this.BeginExecution(testModule, testModuleData);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the included variations for the given module
        /// </summary>
        /// <param name="module">The test module data</param>
        /// <param name="includedPaths">The included paths</param>
        /// <param name="excludedPaths">The excluded paths</param>
        /// <param name="logWriter">optional log writer in case something goes wrong</param>
        /// <returns>The included test items without the excluded items</returns>
        internal static IEnumerable<TestItemData> GetIncludedVariations(TestModuleData module, IEnumerable<string> includedPaths, IEnumerable<string> excludedPaths, ITestLogWriter logWriter)
        {
            ExceptionUtilities.CheckArgumentNotNull(module, "module");
            ExceptionUtilities.CheckArgumentNotNull(includedPaths, "includedPaths");
            ExceptionUtilities.CheckArgumentNotNull(excludedPaths, "excludedPaths");

            var allPossibleItems = module.GetAllChildrenRecursive().Where(i => i.IsVariation).ToList();

            var includedItems = new List<TestItemData>();
            bool anyIncludedPath = false;
            foreach (var includedPath in includedPaths)
            {
                anyIncludedPath = true;

                var toAdd = FilterItemsByPath(allPossibleItems, includedPath).ToList();
                if (toAdd.Count > 0)
                {
                    includedItems.AddRange(toAdd);

                    // TODO: should we remove them?
                    // It seems like it would make subsequent lookups faster and avoid the possibility of double-including something
                    toAdd.ForEach(i => allPossibleItems.Remove(i));
                }
                else if (logWriter != null)
                {
                    var safeString = includedPath.Replace('/', '\\');
                    logWriter.WriteLine(LogLevel.Warning, string.Format(CultureInfo.InvariantCulture, "No test items found for path '{0}' in module '{1}'", safeString, module.Metadata.Name));
                }
            }

            // special case, if no includes are specified, just take everything
            if (!anyIncludedPath)
            {
                includedItems = allPossibleItems;
            }

            foreach (var excludedPath in excludedPaths)
            {
                var toRemove = FilterItemsByPath(includedItems, excludedPath).ToList();
                toRemove.ForEach(i => includedItems.Remove(i));
            }

            return includedItems;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the included variations for the given module
        /// </summary>
        /// <param name="module">The test module data</param>
        /// <param name="includedPaths">The included paths</param>
        /// <param name="excludedPaths">The excluded paths</param>
        /// <param name="logWriter">optional log writer in case something goes wrong</param>
        /// <returns>The included test items without the excluded items</returns>
        internal static IEnumerable <TestItemData> GetIncludedVariations(TestModuleData module, IEnumerable <string> includedPaths, IEnumerable <string> excludedPaths, ITestLogWriter logWriter)
        {
            ExceptionUtilities.CheckArgumentNotNull(module, "module");
            ExceptionUtilities.CheckArgumentNotNull(includedPaths, "includedPaths");
            ExceptionUtilities.CheckArgumentNotNull(excludedPaths, "excludedPaths");

            var allPossibleItems = module.GetAllChildrenRecursive().Where(i => i.IsVariation).ToList();

            var  includedItems   = new List <TestItemData>();
            bool anyIncludedPath = false;

            foreach (var includedPath in includedPaths)
            {
                anyIncludedPath = true;

                var toAdd = FilterItemsByPath(allPossibleItems, includedPath).ToList();
                if (toAdd.Count > 0)
                {
                    includedItems.AddRange(toAdd);

                    // TODO: should we remove them?
                    // It seems like it would make subsequent lookups faster and avoid the possibility of double-including something
                    toAdd.ForEach(i => allPossibleItems.Remove(i));
                }
                else if (logWriter != null)
                {
                    var safeString = includedPath.Replace('/', '\\');
                    logWriter.WriteLine(LogLevel.Warning, string.Format(CultureInfo.InvariantCulture, "No test items found for path '{0}' in module '{1}'", safeString, module.Metadata.Name));
                }
            }

            // special case, if no includes are specified, just take everything
            if (!anyIncludedPath)
            {
                includedItems = allPossibleItems;
            }

            foreach (var excludedPath in excludedPaths)
            {
                var toRemove = FilterItemsByPath(includedItems, excludedPath).ToList();
                toRemove.ForEach(i => includedItems.Remove(i));
            }

            return(includedItems);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the included test items for the given module and suite
        /// </summary>
        /// <param name="module">The test module data</param>
        /// <param name="suite">The test suite</param>
        /// <param name="logWriter">optional log writer in case something goes wrong</param>
        /// <returns>The included test items without the excluded items</returns>
        public static IEnumerable <TestItemData> GetIncludedVariations(TestModuleData module, TestSuite suite, ITestLogWriter logWriter)
        {
            ExceptionUtilities.CheckArgumentNotNull(suite, "suite");
            var included = suite.Items.Where(i => i.IsIncluded).Select(i => i.Name);
            var excluded = suite.Items.Where(i => !i.IsIncluded).Select(i => i.Name);

            return(GetIncludedVariations(module, included, excluded, logWriter));
        }
Exemplo n.º 8
0
 /// <summary>
 /// Runs the specified module.
 /// </summary>
 /// <param name="testModuleData">Data about the test module to run.</param>
 /// <param name="logWriter">The log writer.</param>
 /// <param name="variationsToRun">The variations to run.</param>
 /// <param name="parameters">The test parameters with which to invoke the test module.</param>
 public void Run(TestModuleData testModuleData, ITestLogWriter logWriter, IEnumerable <TestItemData> variationsToRun, IDictionary <string, string> parameters)
 {
     this.Runner.Run(testModuleData, logWriter, variationsToRun, parameters);
 }
 /// <summary>
 /// Initializes a new instance of the TestLogWriterLogger class.
 /// </summary>
 /// <param name="writer">The writer to forward log messages to.</param>
 public TestLogWriterLogger(ITestLogWriter writer)
 {
     this.writer = writer;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Runs the specified module.
 /// </summary>
 /// <param name="testModuleData">Data about the test module to run.</param>
 /// <param name="logWriter">The log writer.</param>
 /// <param name="variationsToRun">The variations to run.</param>
 /// <param name="parameters">The test parameters with which to invoke the test module.</param>
 public void Run(TestModuleData testModuleData, ITestLogWriter logWriter, IEnumerable<TestItemData> variationsToRun, IDictionary<string, string> parameters)
 {
     this.Runner.Run(testModuleData, logWriter, variationsToRun, parameters);
 }