Пример #1
0
 private void getTest(XmlTextReader reader)
 {
     reader.Read();
     if (!_currentAssembly.Tests.Contains(reader.Value))
     {
         _currentAssembly.AddTest(reader.Value);
     }
 }
Пример #2
0
 public void Should_not_run_test_with_ignore_attribute()
 {
     var assemblyPath = Path.GetFullPath(@"AutoTest.TestRunners.MSTest.Tests.TestResource.dll");
     var assembly = new AssemblyOptions(assemblyPath);
     assembly.AddTest("AutoTest.TestRunners.MSTest.Tests.TestResource.TestFixture1.Ignore_Attrib_test");
     var settings = new RunSettings(assembly, new string[] { }, null);
     var runner = new Runner();
     var result = runner.Run(settings);
     Assert.That(result.Count(), Is.EqualTo(0));
 }
 public void When_told_to_run_a_test_that_is_ignored_it_reports_a_ignored_result()
 {
     var runner = new Runner();
     var options = new AssemblyOptions(getAssembly());
     options.AddTest("AutoTest.TestRunners.MSpec.Tests.TestResource.Ignored_test");
     var settings = new RunSettings(options, new string[] { }, null);
     var result = runner.Run(settings);
     Assert.That(result.Count(), Is.EqualTo(1));
     var test = result.ElementAt(0);
     Assert.That(test.State, Is.EqualTo(Shared.Results.TestState.Ignored));
     Assert.That(test.Assembly, Is.EqualTo(getAssembly()));
     Assert.That(test.Runner, Is.EqualTo("MSpec"));
     Assert.That(test.TestFixture, Is.EqualTo("AutoTest.TestRunners.MSpec.Tests.TestResource.Ignored_test"));
     Assert.That(test.TestName, Is.EqualTo("AutoTest.TestRunners.MSpec.Tests.TestResource.Ignored_test"));
 }
 public void when_running_named_test_that_passes()
 {
     var runner = new Runner();
     var options = new AssemblyOptions(getAssembly());
     options.AddTest("AutoTest.TestRunners.SimpleTesting.Tests.Resources.SimpleTestingTests.a_passing_test");
     var settings = new RunSettings(options, new string[] { }, null);
     var result = runner.Run(settings);
     Assert.That(result.Count(), Is.EqualTo(1));
     Assert.That(result.First().State == TestState.Passed);
     Assert.That(!result.First().StackLines.Any());
     Assert.That(result.First().TestDisplayName == "a_passing_test");
     Assert.That(result.First().Runner == "SimpleTesting");
     Assert.AreEqual("AutoTest.TestRunners.SimpleTesting.Tests.Resources.SimpleTestingTests.a_passing_test", result.First().TestName);
     Assert.AreEqual("SimpleTestingTests", result.First().TestFixture);
 }
Пример #5
0
 public void Should_run_single_failing_test()
 {
     var assemblyPath = Path.GetFullPath(@"AutoTest.TestRunners.MSTest.Tests.TestResource.dll");
     var assembly = new AssemblyOptions(assemblyPath);
     assembly.AddTest("AutoTest.TestRunners.MSTest.Tests.TestResource.TestFixture1.Failing_test");
     var settings = new RunSettings(assembly, new string[] { }, null);
     var runner = new Runner();
     var result = runner.Run(settings);
     Assert.That(result.Count(), Is.EqualTo(1));
     var test = result.ElementAt(0);
     Assert.That(test.Runner, Is.EqualTo("MSTest"));
     Assert.That(test.Assembly, Is.EqualTo(assemblyPath));
     Assert.That(test.State, Is.EqualTo(Shared.Results.TestState.Failed));
     Assert.That(test.TestFixture, Is.EqualTo("AutoTest.TestRunners.MSTest.Tests.TestResource.TestFixture1"));
     Assert.That(test.TestName, Is.EqualTo("AutoTest.TestRunners.MSTest.Tests.TestResource.TestFixture1.Failing_test"));
 }
Пример #6
0
 public void Should_run_single_inconclusive_test()
 {
     var assemblyPath = Path.GetFullPath(@"AutoTest.TestRunners.MSTest.Tests.TestResource.dll");
     var assembly = new AssemblyOptions(assemblyPath);
     assembly.AddTest("AutoTest.TestRunners.MSTest.Tests.TestResource.TestFixture1.Inconclusive_test");
     var settings = new RunSettings(assembly, new string[] { });
     var runner = new Runner();
     var result = runner.Run(settings);
     Assert.That(result.Count(), Is.EqualTo(1));
     var test = result.ElementAt(0);
     Assert.That(test.Runner, Is.EqualTo("MSTest"));
     Assert.That(test.Assembly, Is.EqualTo(assemblyPath));
     Assert.That(test.State, Is.EqualTo(Shared.Results.TestState.Ignored));
     Assert.That(test.TestFixture, Is.EqualTo("AutoTest.TestRunners.MSTest.Tests.TestResource.TestFixture1"));
     Assert.That(test.TestName, Is.EqualTo("AutoTest.TestRunners.MSTest.Tests.TestResource.TestFixture1.Inconclusive_test"));
     Assert.That(test.DurationInMilliseconds, Is.GreaterThan(0));
 }
Пример #7
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);
            }
        }
 public void When_told_to_run_a_test_that_fails_it_reports_a_failed_result()
 {
     var runner = new Runner();
     var options = new AssemblyOptions(getAssembly());
     options.AddTest("AutoTest.TestRunners.MSpec.Tests.TestResource.Can_not_add_numbers");
     var settings = new RunSettings(options, new string[] { }, null);
     var result = runner.Run(settings);          
     Assert.That(result.Count(), Is.EqualTo(1));
     var test = result.ElementAt(0);
     Assert.That(test.State, Is.EqualTo(Shared.Results.TestState.Failed));
     Assert.That(test.Assembly, Is.EqualTo(getAssembly()));
     Assert.That(test.Runner, Is.EqualTo("MSpec"));
     Assert.That(test.TestFixture, Is.EqualTo("AutoTest.TestRunners.MSpec.Tests.TestResource.Can_not_add_numbers"));
     Assert.That(test.TestName, Is.EqualTo("AutoTest.TestRunners.MSpec.Tests.TestResource.Can_not_add_numbers"));
     Assert.That(test.Message, Is.EqualTo("I'm failing here"));
     Assert.That(test.StackLines.Count(), Is.EqualTo(2));
 }
Пример #9
0
 private void getTest(XmlTextReader reader)
 {
     reader.Read();
     _currentAssembly.AddTest(reader.Value);
 }
Пример #10
0
 public void Should_run_single_test_and_type()
 {
     var assembly = new AssemblyOptions(
         Path.GetFullPath(@"AutoTest.TestRunners.NUnit.Tests.TestResource.dll")
     );
     assembly.AddTest("AutoTest.TestRunners.NUnit.Tests.TestResource.Fixture1.Should_ignore");
     assembly.AddMember("AutoTest.TestRunners.NUnit.Tests.TestResource.Fixture2");
     var options = new RunSettings(assembly, new string[] {}, "feedback_pipe");
     var results = _runner.Run(options);
     Assert.That(results.Count(), Is.EqualTo(3));
 }
 public void when_running_named_test_that_fails_with_exception()
 {
     var runner = new Runner();
     var options = new AssemblyOptions(getAssembly());
     options.AddTest("AutoTest.TestRunners.SimpleTesting.Tests.Resources.SimpleTestingTests.a_failing_test_with_exception");
     var settings = new RunSettings(options, new string[] { }, null);
     var result = runner.Run(settings);
     Assert.That(result.Count(), Is.EqualTo(1));
     Assert.That(result.First().State == TestState.Failed);
     Assert.That(result.First().StackLines.Any());
     Assert.That(result.First().TestDisplayName == "a_failing_test_with_exception");
 }