Ejemplo n.º 1
0
 public BinaryExecutionOperation(string binaryPath,
                                 IProgressRecorder progressRecorder, ICrossDomainLogger crossDomainLogger)
 {
     this.binaryPath        = binaryPath;
     this.progressRecorder  = progressRecorder;
     this.crossDomainLogger = crossDomainLogger;
 }
Ejemplo n.º 2
0
        public DebugInfoProvider(string binaryPath, ICrossDomainLogger logger)
        {
            this.binaryPath = binaryPath;
            this.logger     = logger;

            try
            {
                session = new DiaSession(binaryPath);
            }
            catch (Exception ex)
            {
                string message = String.Format("Cannot setup debug info for binary '{0}'", binaryPath);

                logger.Debug(new ExceptionLogInfo(ex), message);

                session = noSession;
            }

            try
            {
                asyncMethodHelper = new AsyncMethodHelper(binaryPath);
            }
            catch (Exception ex)
            {
                string message = String.Format("Cannot setup async debug info for binary '{0}'", binaryPath);

                logger.Debug(new ExceptionLogInfo(ex), message);

                asyncMethodHelper = noAsyncHelper;
            }
        }
Ejemplo n.º 3
0
 public int DiscoverTests(string source, ICrossDomainLogger sink)
 {
     var dryRun = new DryRunTestExecutor();
     var session = new TestSession(new CrossDomainSessionLoggerAdapter(sink)) {
         GetTestExecutor = _ => dryRun,
     };
     return RunSession(source, sink, session);
 }
Ejemplo n.º 4
0
        public int ExecuteAll(string binaryPath, IProgressRecorder progressRecorder,
                              IOutputLogger logger, ICrossDomainLogger crossDomainLogger)
        {
            var executionOperation = new BinaryExecutionOperation(binaryPath,
                                                                  progressRecorder, crossDomainLogger);

            return(RunOperationRemotely("all", executionOperation, binaryPath, logger));
        }
Ejemplo n.º 5
0
 public int RunTests(string source, ICrossDomainLogger sink, IEnumerable<string> tests)
 {
     var testsToRun = new HashSet<string>(tests);
     var session = new TestSession(new CrossDomainSessionLoggerAdapter(sink)) {
         ShouldSkipTest = test => !testsToRun.Contains(test.Name),
     };
     return RunSession(source, sink, session);
 }
            public void Execute(
                IBinaryTestExecutor binaryTestExecutor,
                IProgressRecorder progressRecorder,
                IOutputLogger outputLogger, ICrossDomainLogger crossDomainLogger)
            {
                // TODO pass canceler to binaryTestExecutor.Execute

                binaryTestExecutor.ExecuteAll(BinaryPath, progressRecorder, outputLogger, crossDomainLogger);
            }
Ejemplo n.º 7
0
        public int ExecuteSelected(string binaryPath, IEnumerable <string> testCaseFullNames,
                                   IProgressRecorder progressRecorder,
                                   IOutputLogger logger, ICrossDomainLogger crossDomainLogger)
        {
            string[] exampleFullNames = testCaseFullNames.ToArray();

            var executionOperation = new SelectionExecutionOperation(binaryPath, exampleFullNames,
                                                                     progressRecorder, crossDomainLogger);

            return(RunOperationRemotely("selected", executionOperation, binaryPath, logger));
        }
            public void Execute(
                IBinaryTestExecutor binaryTestExecutor,
                IProgressRecorder progressRecorder,
                IOutputLogger outputLogger, ICrossDomainLogger crossDomainLogger)
            {
                var testCaseFullNames = testCaseGroup.Select(tc => tc.FullyQualifiedName);

                // TODO pass canceler to binaryTestExecutor.Execute

                binaryTestExecutor.ExecuteSelected(BinaryPath, testCaseFullNames, progressRecorder, outputLogger, crossDomainLogger);
            }
Ejemplo n.º 9
0
        public virtual void before_each()
        {
            autoSubstitute = new AutoSubstitute();

            proxyableExecutor = Substitute.For <IProxyableTestExecutor>();

            remoteRunner = autoSubstitute.SubstituteFor <ICrossDomainRunner <IProxyableTestExecutor, int> >();

            progressRecorder = autoSubstitute.Resolve <IProgressRecorder>();

            logger            = autoSubstitute.Resolve <IOutputLogger>();
            crossDomainLogger = autoSubstitute.Resolve <ICrossDomainLogger>();

            executor = autoSubstitute.Resolve <BinaryTestExecutor>();
        }
Ejemplo n.º 10
0
        public virtual void before_each()
        {
            autoSubstitute = new AutoSubstitute();

            proxyableDiscoverer = Substitute.For <IProxyableTestDiscoverer>();

            remoteRunner = autoSubstitute.SubstituteFor <
                ICrossDomainRunner <IProxyableTestDiscoverer, DiscoveredExample[]> >();

            fileService = autoSubstitute.Resolve <IFileService>();

            logger            = autoSubstitute.Resolve <IOutputLogger>();
            crossDomainLogger = autoSubstitute.Resolve <ICrossDomainLogger>();

            discoverer = autoSubstitute.Resolve <BinaryTestDiscoverer>();
        }
Ejemplo n.º 11
0
        public IEnumerable <DiscoveredExample> Discover(string binaryPath,
                                                        IOutputLogger logger, ICrossDomainLogger crossDomainLogger)
        {
            if (!NSpecLibraryFound(binaryPath))
            {
                logger.Debug(String.Format("Skipping binary '{0}' because it does not reference nspec library", binaryPath));

                return(new DiscoveredExample[0]);
            }
            else
            {
                var discoveryOperation = new BinaryDiscoveryOperation(binaryPath, crossDomainLogger);

                return(RunOperationRemotely(discoveryOperation, binaryPath, logger));
            }
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 14
0
 public int ExecuteAll(string binaryPath,
                       IProgressRecorder progressRecorder, ICrossDomainLogger logger)
 {
     return(Execute(binaryPath, RunnableContextFinder.RunAll, progressRecorder, logger));
 }
Ejemplo n.º 15
0
 public SelectionExecutionOperation(string binaryPath, string[] exampleFullNames,
                                    IProgressRecorder progressRecorder, ICrossDomainLogger crossDomainLogger)
     : base(binaryPath, progressRecorder, crossDomainLogger)
 {
     this.exampleFullNames = exampleFullNames;
 }
Ejemplo n.º 16
0
 public ContextExecutor(ILiveFormatter executionReporter, ICrossDomainLogger logger)
 {
     this.executionReporter = executionReporter;
     this.logger            = logger;
 }
Ejemplo n.º 17
0
 private int RunSession(string source, ICrossDomainLogger sink, TestSession session)
 {
     runner.RunTests(session, CrossDomainConeRunner.LoadTestAssemblies(new[] {source}, sink.Error));
     return 0;
 }
Ejemplo n.º 18
0
 public BinaryDiscoveryOperation(string binaryPath, ICrossDomainLogger crossDomainLogger)
 {
     this.binaryPath        = binaryPath;
     this.crossDomainLogger = crossDomainLogger;
 }
Ejemplo n.º 19
0
 public int ExecuteSelection(string binaryPath, string[] exampleFullNames,
                             IProgressRecorder progressRecorder, ICrossDomainLogger logger)
 {
     return(Execute(binaryPath, exampleFullNames, progressRecorder, logger));
 }
Ejemplo n.º 20
0
        public virtual void before_each()
        {
            autoSubstitute = new AutoSubstitute();

            logger = autoSubstitute.Resolve <ICrossDomainLogger>();
        }