Example #1
0
        public May<TestsLoadContext> LoadTests(string assemblyPath)
        {
            _log.Info("MsTest loading tests...");
            var cci = new CciModuleSource(assemblyPath);

            var visitor = new MsTestTestsVisitor();
            var traverser = new CodeTraverser
            {
                PreorderVisitor = visitor
            };

            traverser.Traverse(cci.Module.Module);

            var classes = visitor.Classes.Where(c => c.Children.Count != 0).ToList();
            if(classes.Count != 0)
            {
                _log.Info("Tests loaded ("+ classes.Count + " classes).");
                return new May<TestsLoadContext>(new TestsLoadContext(FrameWorkName, classes));
            }
            else
            {
                _log.Info("No tests found.");
                return May.NoValue;
            }
        }
        private List<MethodIdentifier> FindCoveringTests(CciModuleSource module, ICodePartsMatcher targetsMatcher)
        {
            _log.Debug("Scanning " + module.Module.Name + " for selected covering tests. ");
            var visitor = new CoveringTestsVisitor(targetsMatcher);

            var traverser = new CodeTraverser
            {
                PreorderVisitor = visitor
            };
            
            traverser.Traverse(module.Decompile(module.Module));
            _log.Debug("Finished scanning module"+ module.Module.Name + ". Found " + visitor.FoundTests.Count+
                ". Scanned total: " + visitor.ScannedMethods + " methods and "+
                visitor.ScannedMethodCalls+" method calls.");

            _log.Debug("Listing found tests: ");
            foreach (var methodIdentifier in visitor.FoundTests)
            {
                _log.Debug("Test: "+ methodIdentifier);
            }

            if (visitor.IsChoiceError)
            {
                throw new TestWasSelectedToMutateException();
            }
            return visitor.FoundTests.ToList();
        }