internal static ProcessArgumentBuilder GetMSTestArguments(this SpecFlowContext context,
                                                                  FilePath projectFile,
                                                                  ICakeEnvironment environment)
        {
            var builder = new ProcessArgumentBuilder();

            builder.Append("mstestexecutionreport");

            // Set the project file
            builder.AppendQuoted(projectFile.MakeAbsolute(environment).FullPath);

            var arguments = context.RenderArguments();

            // Set the test result
            var testResultMatch = Regex.Match(arguments, "\\/resultsfile:\\s*((?:\".+?\"|[^\\s]+))", RegexOptions.IgnoreCase);

            if (testResultMatch.Success && testResultMatch.Groups[1].Success)
            {
                builder.AppendSwitch("/testResult", ":", testResultMatch.Groups[1].Value);
            }
            else
            {
                throw new CakeException("MSTest must contain argument \"/resultsfile:<filename>\"");
            }

            return(builder);
        }
        internal static ProcessArgumentBuilder GetNUnitArguments(this SpecFlowContext context,
                                                                 FilePath projectFile,
                                                                 ICakeEnvironment environment)
        {
            var builder = new ProcessArgumentBuilder();

            builder.Append("nunitexecutionreport");

            // Set the project file
            builder.AppendQuoted(projectFile.MakeAbsolute(environment).FullPath);

            var arguments = context.RenderArguments();

            // Set the xml test result
            var xmlTestResultMatch = Regex.Match(arguments, "\"--result=([^;]+);format=nunit2", RegexOptions.IgnoreCase);

            if (xmlTestResultMatch.Success && xmlTestResultMatch.Groups[1].Success)
            {
                builder.AppendSwitch("/xmlTestResult", ":", xmlTestResultMatch.Groups[1].Value.Quote());
            }
            else
            {
                throw new CakeException("NUnit3 must contain argument \"--result=<filename>;format=nunit2\"");
            }

            // Set the test output
            var testOutputMatch = Regex.Match(arguments, "\"--out=([^\"]+)\"", RegexOptions.IgnoreCase);

            if (testOutputMatch.Success && testOutputMatch.Groups[1].Success)
            {
                builder.AppendSwitch("/testOutput", ":", testOutputMatch.Groups[1].Value.Quote());
            }
            else
            {
                throw new CakeException("NUnit3 must contain argument \"--out=<filename>\"");
            }

            // Check for labels switch
            var testLabelsMatch = Regex.Match(arguments, "--labels=All", RegexOptions.IgnoreCase);

            if (!testLabelsMatch.Success)
            {
                throw new CakeException("NUnit3 must contain argument \"--labels=All\"");
            }

            return(builder);
        }