/src/test/java/com/atlassian/bamboo/plugin/dotnet/tests/MSTestResultsParserTest.java
Java | 106 lines | 86 code | 17 blank | 3 comment | 1 complexity | 0a370575b52eef07539a579c3513cc61 MD5 | raw file
Possible License(s): BSD-3-Clause
- package com.atlassian.bamboo.plugin.dotnet.tests;
- import com.atlassian.bamboo.plugin.dotnet.tests.mstest.MSTestXmlTestResultsParser;
- import com.atlassian.bamboo.results.tests.TestResults;
- import com.atlassian.bamboo.resultsummary.tests.TestState;
- import com.atlassian.bamboo.utils.BambooTestUtils;
- import org.junit.Test;
- import static org.junit.Assert.assertEquals;
- import static org.junit.Assert.assertFalse;
- /**
- * @author Ross Rowe
- */
- public class MSTestResultsParserTest
- {
- private static final String[] SAMPLE_FILES = new String[]{"com/atlassian/bamboo/plugin/dotnet/tests/sample.trx", "com/atlassian/bamboo/plugin/dotnet/tests/TestResult.trx"};
- private static final String ENTRIES_WITH_SAME_NAME = "com/atlassian/bamboo/plugin/dotnet/tests/build_WIN-BLD1+2009-08-27+11_43_16.trx";
- private static final String VS2010_Format = "com/atlassian/bamboo/plugin/dotnet/tests/vs2010.trx";
- private static final String Kalamon_Format = "com/atlassian/bamboo/plugin/dotnet/tests/kalamon.trx";
- private static final String NANT41 = "com/atlassian/bamboo/plugin/dotnet/tests/BigLebowski.trx";
- private static final String BSP_3531_TRX = "BSP-3531.trx";
- private static final String BSP_5353_TRX = "com/atlassian/bamboo/plugin/dotnet/tests/BSP-5353.trx";
- private static final String VS2010_ERROR_TRX = "com/atlassian/bamboo/plugin/dotnet/tests/VS2010_ERROR.trx";
- private static final double DELTA = 0.0000001;
- @Test
- public void parseNewFormat() throws Exception {
- for (String fileName : SAMPLE_FILES) {
- TestResultsParser parser = new MSTestXmlTestResultsParser();
- parser.parse(BambooTestUtils.getInputStream(fileName));
- assertFalse(parser.getSuccessfulTests().isEmpty());
- }
- }
- @Test
- public void entriesWithSameName() throws Exception {
- TestResultsParser parser = new MSTestXmlTestResultsParser();
- parser.parse(BambooTestUtils.getInputStream(ENTRIES_WITH_SAME_NAME));
- assertFalse(parser.getSuccessfulTests().isEmpty());
- }
- @Test
- public void vs2010Format() throws Exception {
- TestResultsParser parser = new MSTestXmlTestResultsParser();
- parser.parse(BambooTestUtils.getInputStream(VS2010_Format));
- assertFalse(parser.getSuccessfulTests().isEmpty());
- }
- @Test
- public void vsKalamonFormat() throws Exception {
- TestResultsParser parser = new MSTestXmlTestResultsParser();
- parser.parse(BambooTestUtils.getInputStream(Kalamon_Format));
- assertFalse(parser.getSuccessfulTests().isEmpty());
- }
- @Test
- public void nant41() throws Exception {
- TestResultsParser parser = new MSTestXmlTestResultsParser();
- parser.parse(BambooTestUtils.getInputStream(NANT41));
- assertFalse(parser.getSuccessfulTests().isEmpty());
-
- }
- @Test
- public void regressionBSP3531() throws Exception
- {
- TestResultsParser parser = new MSTestXmlTestResultsParser();
- parser.parse(BambooTestUtils.getInputStream(BSP_3531_TRX, this.getClass()));
- assertEquals(230, parser.getSuccessfulTests().size());
- final TestResults testResults_0 = parser.getSuccessfulTests().get(0);
- assertEquals("Ident.ObjectModel.Tests.DataTypes.ApprovalFixture", testResults_0.getClassName());
- assertEquals("Approval test data factory validation", testResults_0.getMethodName());
- assertEquals("Approval_TestDataFactoryValidation", testResults_0.getActualMethodName());
- assertEquals(TestState.SUCCESS, testResults_0.getState());
- assertEquals("11.2608753", testResults_0.getDuration());
- assertEquals(11.2608753, testResults_0.getDurationInSeconds(), DELTA);
- }
- @Test
- public void regressionBSP5353() throws Exception
- {
- TestResultsParser parser = new MSTestXmlTestResultsParser();
- parser.parse(BambooTestUtils.getInputStream(BSP_5353_TRX, this.getClass()));
- assertEquals(19, parser.getFailedTests().size());
- }
- @Test
- public void inconclusiveTests() throws Exception {
- TestResultsParser parser = new MSTestXmlTestResultsParser();
- parser.parse(BambooTestUtils.getInputStream(NANT41));
- assertFalse(parser.getInconclusiveTests().isEmpty());
- }
- @Test
- public void errorTests() throws Exception {
- TestResultsParser parser = new MSTestXmlTestResultsParser();
- parser.parse(BambooTestUtils.getInputStream(VS2010_ERROR_TRX));
-
- assertEquals(1, parser.getSuccessfulTests().size());
- assertEquals(4, parser.getFailedTests().size());
- }
- }