Пример #1
0
        int Execute(string binaryPath, string[] exampleFullNames,
                    IProgressRecorder progressRecorder, ICrossDomainLogger logger)
        {
            string scenario = (exampleFullNames == RunnableContextFinder.RunAll ? "all" : "selected");

            logger.Debug(String.Format("Start executing {0} tests locally in binary '{1}'", scenario, binaryPath));

            int count;

            try
            {
                var runnableContextFinder = new RunnableContextFinder();

                var runnableContexts = runnableContextFinder.Find(binaryPath, exampleFullNames);

                var executedExampleMapper = new ExecutedExampleMapper();

                var executionReporter = new ExecutionReporter(progressRecorder, executedExampleMapper);

                var contextExecutor = new ContextExecutor(executionReporter, logger);

                count = contextExecutor.Execute(runnableContexts);
            }
            catch (Exception ex)
            {
                // report problem and return, without letting exception cross app domain boundary

                count = 0;

                var exInfo  = new ExceptionLogInfo(ex);
                var message = String.Format("Exception thrown while executing tests locally in binary '{0}'", binaryPath);

                logger.Error(exInfo, message);
            }

            logger.Debug(String.Format("Finish executing {0} tests locally in binary '{1}'", count, binaryPath));

            return(count);
        }
        public DiscoveredExample[] Discover(string binaryPath, ICrossDomainLogger logger)
        {
            logger.Debug(String.Format("Start discovering tests locally in binary '{0}'", binaryPath));

            DiscoveredExample[] discoveredExampleArray;

            try
            {
                var exampleFinder = new ExampleFinder();

                var examples = exampleFinder.Find(binaryPath);

                var debugInfoProvider = new DebugInfoProvider(binaryPath, logger);

                var discoveredExampleMapper = new DiscoveredExampleMapper(binaryPath, debugInfoProvider);

                var discoveredExamples = examples.Select(discoveredExampleMapper.FromExample);

                discoveredExampleArray = discoveredExamples.ToArray();
            }
            catch (Exception ex)
            {
                // report problem and return, without letting exception cross app domain boundary

                discoveredExampleArray = new DiscoveredExample[0];

                var exInfo  = new ExceptionLogInfo(ex);
                var message = String.Format("Exception thrown while discovering tests locally in binary '{0}'", binaryPath);

                logger.Error(exInfo, message);
            }

            logger.Debug(String.Format("Finish discovering {0} tests locally in binary '{1}'", discoveredExampleArray.Length, binaryPath));

            return(discoveredExampleArray);
        }