Esempio n. 1
0
        public async Task <TestSuites> Publish(string url, string domain, string project)
        {
            TestSuites testSuites         = null;
            GetRequest testSetRunsRequest = GetRunEntityTestSetRunsRequest(_client, _runId);
            Response   response           = await testSetRunsRequest.Execute();

            var    testInstanceRun = GetTestInstanceRun(response);
            string entityName      = await GetEntityName();

            if (testInstanceRun?.Any() == true)
            {
                testSuites = new JUnitParser(_entityId).ToModel(testInstanceRun, entityName, url, domain, project);
            }

            return(testSuites);
        }
Esempio n. 2
0
        public void PublishBasicXUnitResults()
        {
            SetupMocks();
            string xunitResultsToBeRead = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                          "<assemblies>" +
                                          "<assembly name = \"C:\\Users\\somerandomusername\\Source\\Workspaces\\p1\\ClassLibrary2\\ClassLibrary2\\bin\\Debug\\ClassLibrary2.DLL\">" +
                                          "<class name=\"MyFirstUnitTests.Class1\">" +
                                          "<test name=\"MyFirstUnitTests.Class1.FailingTest\">" +
                                          "</test>" +
                                          "</class>" +
                                          "</assembly>" +
                                          "</assemblies>";

            string           resultFile      = TestUtil.WriteAllTextToTempFile(xunitResultsToBeRead, "xml");
            JUnitParser      reader          = new JUnitParser();
            TestRunContext   runContext      = new TestRunContext();
            TestDataProvider runDataProvider = reader.ParseTestResultFiles(_ec.Object, runContext, new List <string> {
                resultFile
            });
            List <TestRunData> runData = runDataProvider.GetTestRunData();

            Assert.Equal(1, runData[0].AttachmentsFilePathList.Count);
            CleanupTempFile(resultFile);
        }
Esempio n. 3
0
        public void PublishBasicNestedJUnitResults()
        {
            SetupMocks();
            string junitResultsToBeRead = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                                          + "<testsuites>"
                                          + "<testsuite name=\"com.contoso.billingservice.ConsoleMessageRendererTest\" errors=\"0\" failures=\"1\" skipped=\"0\" tests=\"2\" time=\"0.006\" timestamp=\"2015-04-06T21:56:24\">"
                                          + "<testsuite errors=\"0\" failures=\"1\" hostname=\"mghost\" name=\"com.contoso.billingservice.ConsoleMessageRendererTest\" skipped=\"0\" tests=\"2\" time=\"0.006\" timestamp=\"2015-04-06T21:56:24\">"
                                          + "<testcase classname=\"com.contoso.billingservice.ConsoleMessageRendererTest\" name=\"testRenderNullMessage\" testType=\"asdasdas\" time=\"0.001\" />"
                                          + "<testcase classname=\"com.contoso.billingservice.ConsoleMessageRendererTest\" name=\"testRenderMessage\" time=\"0.003\">"
                                          + "<failure type=\"junit.framework.AssertionFailedError\">junit.framework.AssertionFailedError at com.contoso.billingservice.ConsoleMessageRendererTest.testRenderMessage(ConsoleMessageRendererTest.java:11)"
                                          + "</failure>"
                                          + "</testcase >"
                                          + "<system-out><![CDATA[Hello World!]]>"
                                          + "</system-out>"
                                          + "<system-err><![CDATA[]]></system-err>"
                                          + "</testsuite>"
                                          + "</testsuite>"
                                          + "</testsuites>";

            string           resultFile      = TestUtil.WriteAllTextToTempFile(junitResultsToBeRead, "xml");
            JUnitParser      reader          = new JUnitParser();
            TestRunContext   runContext      = new TestRunContext();
            TestDataProvider runDataProvider = reader.ParseTestResultFiles(_ec.Object, runContext, new List <string> {
                resultFile
            });
            List <TestRunData> runData = runDataProvider.GetTestRunData();

            Assert.NotNull(runData[0].TestResults);
            Assert.Equal(2, runData[0].TestResults.Count);
            Assert.Equal(1, runData[0].TestResults.Count(r => r.Outcome.Equals("Passed")));
            Assert.Equal(null, runData[0].TestResults[0].AutomatedTestId);
            Assert.Equal(null, runData[0].TestResults[0].AutomatedTestTypeId);
            Assert.Equal(1, runData[0].TestResults.Count(r => r.Outcome.Equals("Failed")));
            Assert.Equal("com.contoso.billingservice.ConsoleMessageRendererTest", runData[0].RunCreateModel.Name);
            CleanupTempFile(resultFile);
        }