Exemplo n.º 1
0
        private static void StartTestRunner(Device device)
        {
            string currentPath     = Directory.GetCurrentDirectory();
            string baseProjectPath = Path.GetFullPath(Path.Combine(currentPath, @"..\..\..\"));
            string runnerPath      = Path.GetFullPath(Path.Combine(currentPath, @"..\..\..\")) + @"\NunitConsole";

            DirectoryInfo testRunDirectory = CopyTestRunner(device, currentPath, runnerPath);

            CloneStripDeviceListForSingleDevice(device, baseProjectPath, testRunDirectory);

            string assemblyArgs = "PerfectoSpecFlow.dll";

            if (device.DeviceDetails.RunWeb)
            {
                assemblyArgs = "PerfectoWebSpecFlow.dll";
            }

            //Use the nunit3 console to run our tests
            //arguments for nunit3 look like:
            //		your-assembly-with-test-cases.dll --result=TestRun.xml;format=nunit2 --where "cat != AppiumTests"
            //Using format=nunit2 for VSTS compatibility (it can't process nunit3 results)
            var arguments = assemblyArgs + " --result=TestRun.xml;format=nunit2";

            Console.WriteLine(device.DeviceDetails.Name + " About to start nunit3-console.exe with the following arguments: " + arguments);

            Trace.TraceInformation(device.DeviceDetails.Name + "About to start nunit3-console.exe with the following arguments: " + arguments);
            Trace.Flush();

            Process          nunitRunnerProcess = new Process();
            ProcessStartInfo nunitStartInfo
                = new ProcessStartInfo(testRunDirectory.FullName
                                       + @"\nunit3-console.exe", arguments);

            nunitStartInfo.WindowStyle = ProcessWindowStyle.Normal;
            //Must set WorkingDirectory to execute from the location of the testrunner or it will pull from this exe's config
            nunitStartInfo.UseShellExecute         = false;
            nunitStartInfo.WorkingDirectory        = testRunDirectory.FullName;
            nunitRunnerProcess.StartInfo           = nunitStartInfo;
            nunitRunnerProcess.OutputDataReceived += (sender, args) => OnDataReceived(args.Data);
            nunitRunnerProcess.Start();

            lock (LockObject)
            {
                ParallelProcessObserver.AddProcess(nunitRunnerProcess);
            }
        }
Exemplo n.º 2
0
        private static void StartTestRunner(Device device, string assemblyArgs, string whereFilter)
        {
            string currentPath     = Directory.GetCurrentDirectory();
            string baseProjectPath = Path.GetFullPath(Path.Combine(currentPath, @"..\..\..\"));
            string runnerPath      = Path.GetFullPath(Path.Combine(currentPath, @"..\..\..\")) + @"\NunitConsole";

            DirectoryInfo testRunDirectory = CopyTestRunner(device, currentPath, runnerPath);

            CloneStripDeviceListForSingleDevice(device, baseProjectPath, testRunDirectory);

            //Use the nunit3 console to run our tests
            //arguments for nunit3 look like:
            //		your-assembly-with-test-cases.dll --result=TestRun.xml;format=nunit2 --where "cat != AppiumTests"
            //Using format=nunit2 for VSTS compatibility (it can't process nunit3 results)
            var arguments = assemblyArgs + " --result=TestRun.xml;format=nunit2";

            string toSkip = GetTestsToSkipForDevice(device);

            string whereOptions = string.Empty;

            if (!string.IsNullOrEmpty(toSkip))
            {
                whereOptions = toSkip;
            }

            if (!string.IsNullOrEmpty(whereFilter) && !string.IsNullOrEmpty(whereOptions))
            {
                whereOptions += " and " + whereFilter;
            }
            else if (!string.IsNullOrEmpty(whereFilter) && string.IsNullOrEmpty(whereOptions))
            {
                whereOptions += " " + whereFilter;
            }

            //if device config needs to skip or where filter was passed in -add a where clause to our console argument
            if (!string.IsNullOrEmpty(whereOptions))
            {
                const string quote = "\"";
                arguments += " --where " + quote + whereOptions + quote;
            }

            Console.WriteLine("About to start nunit3-console.exe with the following arguments: " + arguments);

            Trace.TraceInformation("About to start nunit3-console.exe with the following arguments: " + arguments);
            Trace.Flush();


            Process          nunitRunnerProcess = new Process();
            ProcessStartInfo nunitStartInfo
                = new ProcessStartInfo(testRunDirectory.FullName
                                       + @"\nunit3-console.exe", arguments);

            nunitStartInfo.WindowStyle = ProcessWindowStyle.Normal;
            //Must set WorkingDirectory to execute from the location of the testrunner or it will pull from this exe's config
            nunitStartInfo.UseShellExecute         = false;
            nunitStartInfo.WorkingDirectory        = testRunDirectory.FullName;
            nunitRunnerProcess.StartInfo           = nunitStartInfo;
            nunitRunnerProcess.OutputDataReceived += (sender, args) => OnDataReceived(args.Data);

            nunitRunnerProcess.Start();

            lock (LockObject)
            {
                ParallelProcessObserver.AddProcess(nunitRunnerProcess);
            }
        }