private void getRunner(XmlTextReader reader)
 {
     if (reader.IsEmptyElement)
     {
         var id = reader.GetAttribute("id");
         if (_options.TestRuns.Count(x => x.ID.Equals(id)) == 0)
         {
             _options.AddTestRun(new RunnerOptions(id));
         }
     }
     else if (reader.NodeType == XmlNodeType.EndElement)
     {
         if (_options.TestRuns.Count(x => x.ID.Equals(_currentRunner.ID)) == 0)
         {
             _options.AddTestRun(_currentRunner);
         }
     }
     else
     {
         var id = reader.GetAttribute("id");
         _currentRunner = _options.TestRuns.FirstOrDefault(x => x.ID.Equals(id));
         if (_currentRunner == null)
         {
             _currentRunner = new RunnerOptions(id);
         }
     }
 }
        public void Should_produce_xml()
        {
            var plugins = new List<Plugin>();
            var options = new RunOptions();
            plugins.Add(new Plugin(@"C:\Some\Path\Assembly.dll", "This.Is.Full.Type.Name.For.Class.Implementing.IAutoTestNetTestRunner"));
            plugins.Add(new Plugin(@"C:\Some\Path\Assembly.dll", "Some.Class.Name"));

            var runner1 = new RunnerOptions("nunit");
            runner1.AddCategories(new string[] { "SomeTestCategory", "SomeOtherTestCategory" });
            var assembly1 = new AssemblyOptions(@"C:\my\testassembly.dll");
            assembly1.HasBeenVerified(true);
            assembly1.AddTests(new string[] { "testassembly.class.test1", "testassembly.class.test2" });
            assembly1.AddMembers(new string[] { "testassembly.class2", "testassembly.class3" });
            assembly1.AddNamespaces(new string[] { "testassembly.somenamespace1", "testassembly.somenamespace2" });
            runner1.AddAssemblies(new AssemblyOptions[] { assembly1, new AssemblyOptions(@"C:\my\anothernunitassembly.dll") });
            options.AddTestRun(runner1);

            var runner2 = new RunnerOptions("another");
            runner2.AddAssembly(new AssemblyOptions(@"C:\my\other\testassembly.dll"));
            options.AddTestRun(runner2);
            
            var writer = new OptionsXmlWriter(plugins, options);
            var file = Path.GetTempFileName();
            writer.Write(file);

            var path = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
            var original = File.ReadAllText(file).Replace("\r\n", "\n");
            var generated = File.ReadAllText(Path.Combine(path, "TestOptionsCorrected.xml")).Replace("\r\n", "\n");
            Assert.That(original, Is.EqualTo(generated));
        }
示例#3
0
 private static RunOptions getRunOptions()
 {
     var assembly = new AssemblyOptions(@"P:\projects\mooseprofiler.git\MMProfiler\main\x86\Debug\Test.Target.dll");
     var run = new RunnerOptions("NUnit");
     run.AddAssembly(assembly);     
     var optoins = new RunOptions();
     optoins.AddTestRun(run);
     return optoins;
 }
        public void Should_group_by_assembly()
        {
            var locator = MockRepository.GenerateMock<IAssemblyReader>();
            locator.Stub(x => x.GetTargetFramework("Assembly1")).Return(new Version(2, 0));
            locator.Stub(x => x.GetTargetFramework("Assembly2")).Return(new Version(4, 0));
            locator.Stub(x => x.GetTargetFramework("Assembly3")).Return(new Version(2, 0));
            locator.Stub(x => x.GetTargetFramework("Assembly4")).Return(new Version(2, 0));
            locator.Stub(x => x.GetTargetFramework("Assembly5")).Return(new Version(2, 0));
            locator.Stub(x => x.GetTargetFramework("Assembly6")).Return(new Version(4, 0));

            locator.Stub(x => x.GetPlatform("Assembly1")).Return(Platform.AnyCPU);
            locator.Stub(x => x.GetPlatform("Assembly2")).Return(Platform.AnyCPU);
            locator.Stub(x => x.GetPlatform("Assembly3")).Return(Platform.AnyCPU);
            locator.Stub(x => x.GetPlatform("Assembly4")).Return(Platform.AnyCPU);
            locator.Stub(x => x.GetPlatform("Assembly5")).Return(Platform.x86);
            locator.Stub(x => x.GetPlatform("Assembly6")).Return(Platform.x86);

            var options = new RunOptions();
            var runner = new RunnerOptions("NUnit");
            runner.AddAssemblies(new AssemblyOptions[] { new AssemblyOptions("Assembly1"), new AssemblyOptions("Assembly2") });
            options.AddTestRun(runner);
            runner = new RunnerOptions("NUnit");
            runner.AddAssemblies(new AssemblyOptions[] { new AssemblyOptions("Assembly3"), new AssemblyOptions("Assembly5") });
            options.AddTestRun(runner);
            runner = new RunnerOptions("XUnit");
            runner.AddAssemblies(new AssemblyOptions[] { new AssemblyOptions("Assembly4"), new AssemblyOptions("Assembly6") });
            options.AddTestRun(runner);

            var assembler = new TargetedRunAssembler(options, locator);
            var targeted = assembler.Assemble();

            Assert.That(targeted.Count(), Is.EqualTo(4));
            Assert.That(targeted.ElementAt(0).Platform, Is.EqualTo(Platform.AnyCPU));
            Assert.That(targeted.ElementAt(0).TargetFramework, Is.EqualTo(new Version(2, 0)));
            Assert.That(targeted.ElementAt(0).Runners.Count(), Is.EqualTo(2));
            Assert.That(targeted.ElementAt(0).Runners.Count(), Is.EqualTo(2));
            Assert.That(targeted.ElementAt(0).Runners.ElementAt(0).ID, Is.EqualTo("NUnit"));
            Assert.That(targeted.ElementAt(0).Runners.ElementAt(0).Assemblies.ElementAt(0).Assembly, Is.EqualTo("Assembly1"));
            Assert.That(targeted.ElementAt(0).Runners.ElementAt(0).Assemblies.ElementAt(1).Assembly, Is.EqualTo("Assembly3"));
            Assert.That(targeted.ElementAt(0).Runners.ElementAt(1).ID, Is.EqualTo("XUnit"));
            Assert.That(targeted.ElementAt(0).Runners.ElementAt(1).Assemblies.ElementAt(0).Assembly, Is.EqualTo("Assembly4"));
            Assert.That(targeted.ElementAt(1).Platform, Is.EqualTo(Platform.AnyCPU));
            Assert.That(targeted.ElementAt(1).TargetFramework, Is.EqualTo(new Version(4, 0)));
            Assert.That(targeted.ElementAt(1).Runners.ElementAt(0).ID, Is.EqualTo("NUnit"));
            Assert.That(targeted.ElementAt(1).Runners.ElementAt(0).Assemblies.ElementAt(0).Assembly, Is.EqualTo("Assembly2"));
            Assert.That(targeted.ElementAt(2).Platform, Is.EqualTo(Platform.x86));
            Assert.That(targeted.ElementAt(2).TargetFramework, Is.EqualTo(new Version(2, 0)));
            Assert.That(targeted.ElementAt(2).Runners.ElementAt(0).ID, Is.EqualTo("NUnit"));
            Assert.That(targeted.ElementAt(2).Runners.ElementAt(0).Assemblies.ElementAt(0).Assembly, Is.EqualTo("Assembly5"));
            Assert.That(targeted.ElementAt(3).Platform, Is.EqualTo(Platform.x86));
            Assert.That(targeted.ElementAt(3).TargetFramework, Is.EqualTo(new Version(4, 0)));
            Assert.That(targeted.ElementAt(3).Runners.ElementAt(0).ID, Is.EqualTo("XUnit"));
            Assert.That(targeted.ElementAt(3).Runners.ElementAt(0).Assemblies.ElementAt(0).Assembly, Is.EqualTo("Assembly6"));
        }
 private void getRunner(XmlTextReader reader)
 {
     if (reader.IsEmptyElement)
     {
         _options.AddTestRun(new RunnerOptions(reader.GetAttribute("id")));
     }
     else if (reader.NodeType == XmlNodeType.EndElement)
     {
         _options.AddTestRun(_currentRunner);
     }
     else
     {
         _currentRunner = new RunnerOptions(reader.GetAttribute("id"));
     }
 }
        private void parseOptions()
        {
            _options = new RunOptions();
            var nodes = _xml.SelectNodes("run/runner");

            foreach (XmlNode node in nodes)
            {
                XmlNode idNode = node.Attributes.GetNamedItem("id");
                string  id     = null;
                if (idNode != null)
                {
                    id = idNode.InnerXml;
                }
                var runner = new RunnerOptions(id);
                runner.AddCategories(getCategories(node));
                runner.AddAssemblies(getAssemblies(node));
                _options.AddTestRun(runner);
            }
        }
        public void Should_run_tests()
        {
            return;
            var options = new RunOptions();
            var runner = new RunnerOptions("NUnit");
            options.AddTestRun(runner);
            //runner.AddAssembly(new AssemblyOptions(@"C:\Users\ack\src\AutoTest.Net\src\AutoTest.TestRunner\Plugins\AutoTest.TestRunners.NUnit.Tests.TestResource\bin\Debug\AutoTest.TestRunners.NUnit.Tests.TestResource.dll"));
            runner.AddAssembly(new AssemblyOptions(@"C:\Users\Natalia\Documents\Repos\ic-AutoTest.NET4CTDD\2015\src\AutoTest.TestRunner\Plugins\AutoTest.TestRunners.NUnit.Tests.TestResource\bin\Debug\AutoTest.TestRunners.NUnit.Tests.TestResource.dll"));
            //runner.AddAssembly(new AssemblyOptions(@"C:\Users\ack\src\ClassLibrary1-v40\ClassLibrary1-v40\bin\AutoTest.Net\ClassLibrary1-v40.dll"));
            runner.AddAssembly(new AssemblyOptions(@"C:\Users\Natalia\Documents\Visual Studio 2015\Projects\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll"));
            //runner = new RunnerOptions("XUnit");
            runner = new RunnerOptions("MSTest");
            options.AddTestRun(runner);
            runner.AddAssembly(new AssemblyOptions(@"C:\Users\ack\src\AutoTest.Net\src\AutoTest.TestRunner\Plugins\AutoTest.TestRunners.XUnit.Tests.TestResource\bin\AutoTest.Net\AutoTest.TestRunners.XUnit.Tests.TestResource.dll"));
            var process = new TestRunProcess(new feedback());
            var results = process.ProcessTestRuns(options);

            var sb = new StringBuilder();
            sb.AppendLine("");
            foreach (var result in results)
                sb.AppendLine(result.Runner + ", " + result.TestName + ", " + result.Message);

            throw new Exception(sb.ToString());
        }
 private void getRunner(XmlTextReader reader)
 {
     if (reader.IsEmptyElement)
     {
         var id = reader.GetAttribute("id");
         if (_options.TestRuns.Count(x => x.ID.Equals(id)) == 0)
             _options.AddTestRun(new RunnerOptions(id));
     }
     else if (reader.NodeType == XmlNodeType.EndElement)
     {
         if (_options.TestRuns.Count(x => x.ID.Equals(_currentRunner.ID)) == 0)
             _options.AddTestRun(_currentRunner);
     }
     else
     {
         var id = reader.GetAttribute("id");
         _currentRunner = _options.TestRuns.FirstOrDefault(x => x.ID.Equals(id));
         if (_currentRunner == null)
             _currentRunner = new RunnerOptions(id);
     }
 }
示例#9
0
        private static RunnerOptions getTestRunsFor(IAutoTestNetTestRunner instance, RunnerOptions run)
        {
            if (run.ID.ToLower() != "any")
                return run;

            var newRun = new RunnerOptions(run.ID);
            newRun.AddCategories(run.Categories.ToArray());
            foreach (var asm in run.Assemblies)
            {
                if (!asm.IsVerified && !instance.ContainsTestsFor(asm.Assembly))
                    continue;
                var assembly = new AssemblyOptions(asm.Assembly);
                assembly.AddNamespaces(asm.Namespaces.Where(x => asm.IsVerified || instance.ContainsTestsFor(asm.Assembly, x)).ToArray());
                assembly.AddMembers(asm.Members.Where(x => asm.IsVerified || instance.ContainsTestsFor(asm.Assembly, x)).ToArray());
                assembly.AddTests(asm.Tests.Where(x => asm.IsVerified || instance.IsTest(asm.Assembly, x)).ToArray());
                if (hasNoTests(asm) || hasTests(assembly))
                    newRun.AddAssembly(assembly);
            }
            if (newRun.Assemblies.Count() == 0)
                return null;
            return newRun;
        }
示例#10
0
        public void Debug(CacheTestMessage test)
        {
            try
            {
                AutoTest.Core.DebugLog.Debug.WriteDebug("Starting debug session");
                var found = false;
                var targetFramework = "";
                found = setBreakpointFromMethod(test, ref targetFramework);
                if (!found)
                    found = setBreakpointFromStacktrace(test, ref targetFramework);

                if (!found)
                    return;

                var process = new AutoTestRunnerDebugProcess();
                var assembly = test.Assembly;

                AutoTest.Core.DebugLog.Debug.WriteDebug("Starting process suspended");
                var command = "";
                var options = new RunOptions();
                var runner = new RunnerOptions(getTestRunner(TestRunnerConverter.ToString(test.Test.Runner), test.Assembly, test.Test.Name));
                var asm = new AssemblyOptions(test.Assembly);
                asm.AddTest(test.Test.Name);
                runner.AddAssembly(asm);
                options.AddTestRun(runner);
                AutoTest.Core.DebugLog.Debug.WriteDebug(string.Format("Starting {0}", command));
                var processID = process.StartPaused(options, test.Test.Runner);
                try
                {
                    AutoTest.Core.DebugLog.Debug.WriteDebug("Locating debugger for Visual Studio " + _application.Version);
                    var dbg2 = (EnvDTE80.Debugger2)_application.Debugger;
                    var trans = (EnvDTE80.Transport)dbg2.Transports.Item("Default");
                    EnvDTE80.Engine[] dbgeng;
                    if (_application.Version == "9.0")
                    {
                        dbgeng = new EnvDTE80.Engine[] { trans.Engines.Item("Managed") };
                    }
                    else
                    {
                        if (process.Framework == new Version(4, 0))
                            dbgeng = new EnvDTE80.Engine[] { trans.Engines.Item("Managed (v4.0)") };
                        else
                            dbgeng = new EnvDTE80.Engine[] { trans.Engines.Item("Managed (v2.0, v1.1, v1.0)") };
                    }
                    
                    EnvDTE80.Process2 proc2 = null;
                    foreach (EnvDTE80.Process2 proc in dbg2.GetProcesses(trans, null))
                    {
                        if (proc.ProcessID == processID)
                        {
                            proc2 = proc;
                            break;
                        }
                    }
                    if (proc2 != null)
                        proc2.Attach2(dbgeng);
                }
                catch (Exception ex)
                {
                    AutoTest.Core.DebugLog.Debug.WriteException(ex);
                    throw;
                }
                finally
                {
                    AutoTest.Core.DebugLog.Debug.WriteDebug("Resuming process");
                    process.Resume();
                }
            }
            catch (Exception ex)
            {
                AutoTest.Core.DebugLog.Debug.WriteException(ex);
            }
        }
        private RunnerOptions getRunnerOptions(IEnumerable<TestRunInfo> unitInfos, IAutoTestNetTestRunner instance)
        {
            DebugLog.Debug.WriteDetail("Getting runner options for {0}", instance.Identifier);
            var runner = new RunnerOptions(instance.Identifier);
            runner.AddCategories(_configuration.TestCategoriesToIgnore);
            var testRunner = TestRunnerConverter.FromString(instance.Identifier);
            foreach (var info in unitInfos)
            {
				DebugLog.Debug.WriteDetail("Handling {0}", info.Assembly);
				DebugLog.Debug.WriteDetail("About to add assembly");
                var assembly = new AssemblyOptions(info.Assembly);
                assembly.HasBeenVerified(true);
                assembly.AddTests(info.GetTestsFor(testRunner));
                DebugLog.Debug.WriteDetail("Found {0} tests for assembly", assembly.Tests.Count());
                assembly.AddMembers(info.GetMembersFor(testRunner));
                DebugLog.Debug.WriteDetail("Found {0} members for assembly", assembly.Members.Count());
                assembly.AddNamespaces(info.GetNamespacesFor(testRunner));
                DebugLog.Debug.WriteDetail("Found {0} namespaces for assembly", assembly.Namespaces.Count());
                DebugLog.Debug.WriteDetail("Run only specified tests for runner {0} is {1}", testRunner, info.OnlyRunSpcifiedTestsFor(testRunner));
                if (info.OnlyRunSpcifiedTestsFor(testRunner) && assembly.Tests.Count() == 0 && assembly.Members.Count() == 0 && assembly.Namespaces.Count() == 0)
                    continue;
				DebugLog.Debug.WriteDetail("Adding assembly");
                runner.AddAssembly(assembly);
            }
            return runner;
        }
 public void AddTestRun(RunnerOptions runner)
 {
     _runners.Add(runner);
 }
示例#13
0
 public void AddTestRun(RunnerOptions runner)
 {
     _runners.Add(runner);
 }
示例#14
0
 private void mergeCategories(RunnerOptions option, IEnumerable<string> categories)
 {
     var newCategories = categories.Where(x => !option.Categories.Contains(x)).Select(x => x);
     option.AddCategories(newCategories.ToArray());
 }