Пример #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));
        }
Пример #2
0
        private string createInputFile()
        {
            var options = getRunOptions();
            var file    = Path.GetTempFileName();
            var writer  = new OptionsXmlWriter(getPlugins(options), options);

            writer.Write(file);
            return(file);
        }
Пример #3
0
        public int StartPaused(RunOptions options, TestRunner runner)
        {
            var currentPath = Environment.CurrentDirectory;

            try
            {
                Environment.CurrentDirectory = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath);
                using (var assembly = Reflect.On(options.TestRuns.ElementAt(0).Assemblies.ElementAt(0).Assembly))
                {
                    _version = assembly.GetTargetFramework();
                }
                //var wrapper = getWrapper(options, runner);
                var inputFile  = Path.GetTempFileName();
                var outputFile = Path.GetTempFileName();
                var writer     = new OptionsXmlWriter(new Plugin[] {}, options);
                writer.Write(inputFile);
                AutoTest.Core.DebugLog.Debug.WriteDebug("About to debug:");
                AutoTest.Core.DebugLog.Debug.WriteDebug(File.ReadAllText(inputFile));
                var arguments = string.Format("--input=\"{0}\" --output=\"{1}\" --startsuspended --silent", inputFile, outputFile);
                var exe       = new TestProcessSelector().Get(options.TestRuns.ElementAt(0).Assemblies.ElementAt(0).Assembly);
                AutoTest.Core.DebugLog.Debug.WriteDebug("Running: " + exe + " " + arguments);
                _process                                 = new Process();
                _process.StartInfo                       = new ProcessStartInfo(exe, arguments);
                _process.StartInfo.WindowStyle           = ProcessWindowStyle.Hidden;
                _process.StartInfo.RedirectStandardInput = true;
                _process.StartInfo.UseShellExecute       = false;
                _process.StartInfo.CreateNoWindow        = true;
                _process.StartInfo.WorkingDirectory      = Environment.CurrentDirectory;
                _process.Start();
                return(_process.Id);
            }
            catch (Exception ex)
            {
                AutoTest.Core.DebugLog.Debug.WriteException(ex);
            }
            finally
            {
                Environment.CurrentDirectory = currentPath;
            }
            return(0);
        }