Exemple #1
0
        private static string NormalizeOutput(string resultString, string baseDir)
        {
            resultString = resultString.ReplaceIgnoreCase(baseDir, "${BaseDir}");
            resultString = Regex.Replace(resultString, @"\\(Debug|Release)\\", @"\${ConfigurationName}\");
            resultString = Regex.Replace(resultString, @"Test execution time: .*", "Test execution time: ${RunTime}");
            resultString = TestResources.NormalizePointerInfo(resultString);
            resultString = Regex.Replace(resultString, @"Version .*\s*Copyright", "Version ${ToolVersion} Copyright");
            resultString = Regex.Replace(resultString, "Found [0-9]+ tests in executable", "Found ${NrOfTests} tests in executable");

            // exception messages are localized (thanks, MS). Add your own language here...
            resultString = resultString.Replace("   bei ", "   at ");
            resultString = Regex.Replace(resultString, @":Zeile ([0-9]+)\.", ":line $1");

            string testExecutionCompletedPattern = @".*Test execution completed, overall duration: .*\n";

            if (Regex.IsMatch(resultString, testExecutionCompletedPattern))
            {
                resultString  = Regex.Replace(resultString, testExecutionCompletedPattern, "");
                resultString += "\n\nTest execution completed, overall duration: ${OverallDuration}\n";
            }

            string coveragePattern = @"Attachments:\n.*\.coverage\n\n";

            if (Regex.IsMatch(resultString, coveragePattern))
            {
                resultString  = Regex.Replace(resultString, coveragePattern, "");
                resultString += "\n\nGoogle Test Adapter Coverage Marker";
            }
            else
            {
                // workaround for build server - wtf?
                coveragePattern = @"Attachments:\n.*\.coverage\n";
                if (Regex.IsMatch(resultString, coveragePattern))
                {
                    resultString  = Regex.Replace(resultString, coveragePattern, "");
                    resultString += "\nGoogle Test Adapter Coverage Marker";
                }
            }

            string noDataAdapterPattern = "Warning: Could not find diagnostic data adapter 'Code Coverage'. Make sure diagnostic data adapter is installed and try again.\n\n";

            if (Regex.IsMatch(resultString, noDataAdapterPattern))
            {
                resultString  = Regex.Replace(resultString, noDataAdapterPattern, "");
                resultString += "\n\nGoogle Test Adapter Coverage Marker";
            }

            string emptyLinePattern = @"\n\n";

            while (Regex.IsMatch(resultString, emptyLinePattern))
            {
                resultString = Regex.Replace(resultString, emptyLinePattern, "\n");
            }

            return(resultString);
        }
Exemple #2
0
        private void AddInfoFromDetailPane(TestCase testResult, Label label)
        {
            var id = label.AutomationElement.Current.AutomationId;

            switch (id)
            {
            case "detailPanelHeader":
                var name = TestResources.NormalizePointerInfo(label.Text);
                testResult.Name += name;
                if (label.Text != label.HelpText)
                {
                    testResult.FullyQualifiedName += label.HelpText;
                }
                break;

            case "hasSourceToolTip":
                testResult.Source += label.Text;
                break;

            case "testResultSummaryText Failed":
            case "testResultSummaryText Skipped":
            case "testResultSummaryText Passed":
                testResult.Result += TestResources.NormalizePointerInfo(label.Text);
                break;

            case "errorMessageItem":
                testResult.Error += label.Text.ReplaceIgnoreCase(Path.GetDirectoryName(_vsui.SolutionFile), "$(SolutionDir)");
                break;

            case "hyperlinkText":
                testResult.Stacktrace = label.Text.ReplaceIgnoreCase(Path.GetDirectoryName(_vsui.SolutionFile), "$(SolutionDir)");
                break;

            case "sourceTextHeader":
            case "noSourceAvailableToolTip":
            case "elapsedTimeText":
            case "Stacktraceheader":
            case "StackFramePanel":
                // ignore
                break;

            default:
                testResult.Unexpected += $"{id}={label.Text} ";
                break;
            }
        }