示例#1
0
        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.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, "TestOptions.xml")).Replace("\r\n", "\n");

            Assert.That(original, Is.EqualTo(generated));
        }
        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"));
        }
示例#3
0
        private RunOptions getRunOptions()
        {
            var options = new RunOptions();

            foreach (var run in _targetedRun.Runners)
            {
                options.AddTestRun(run);
            }
            return(options);
        }
示例#4
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);
        }
        private RunOptions generateOptions(TestRunInfo[] runInfos)
        {
            var options = new RunOptions();
            var plugins = new PluginLocator().Locate();

            foreach (var plugin in plugins)
            {
                var testRun = getTests(plugin, runInfos);
                if (testRun != null)
                {
                    options.AddTestRun(testRun);
                }
            }

            if (options.TestRuns.Count() == 0)
            {
                return(null);
            }
            return(options);
        }
示例#6
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(string.Format("Managed (v{0}.{1})", process.Framework.Major, process.Framework.Minor)) }
                        }
                        ;
                        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);
            }
        }