PageRenderTime 66ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/java/com/atlassian/bamboo/plugin/dotnet/tests/MSTestResultsParserTest.java

https://bitbucket.org/atlassian/bamboo-dotnet-plugin/
Java | 106 lines | 86 code | 17 blank | 3 comment | 1 complexity | 0a370575b52eef07539a579c3513cc61 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. package com.atlassian.bamboo.plugin.dotnet.tests;
  2. import com.atlassian.bamboo.plugin.dotnet.tests.mstest.MSTestXmlTestResultsParser;
  3. import com.atlassian.bamboo.results.tests.TestResults;
  4. import com.atlassian.bamboo.resultsummary.tests.TestState;
  5. import com.atlassian.bamboo.utils.BambooTestUtils;
  6. import org.junit.Test;
  7. import static org.junit.Assert.assertEquals;
  8. import static org.junit.Assert.assertFalse;
  9. /**
  10. * @author Ross Rowe
  11. */
  12. public class MSTestResultsParserTest
  13. {
  14. private static final String[] SAMPLE_FILES = new String[]{"com/atlassian/bamboo/plugin/dotnet/tests/sample.trx", "com/atlassian/bamboo/plugin/dotnet/tests/TestResult.trx"};
  15. private static final String ENTRIES_WITH_SAME_NAME = "com/atlassian/bamboo/plugin/dotnet/tests/build_WIN-BLD1+2009-08-27+11_43_16.trx";
  16. private static final String VS2010_Format = "com/atlassian/bamboo/plugin/dotnet/tests/vs2010.trx";
  17. private static final String Kalamon_Format = "com/atlassian/bamboo/plugin/dotnet/tests/kalamon.trx";
  18. private static final String NANT41 = "com/atlassian/bamboo/plugin/dotnet/tests/BigLebowski.trx";
  19. private static final String BSP_3531_TRX = "BSP-3531.trx";
  20. private static final String BSP_5353_TRX = "com/atlassian/bamboo/plugin/dotnet/tests/BSP-5353.trx";
  21. private static final String VS2010_ERROR_TRX = "com/atlassian/bamboo/plugin/dotnet/tests/VS2010_ERROR.trx";
  22. private static final double DELTA = 0.0000001;
  23. @Test
  24. public void parseNewFormat() throws Exception {
  25. for (String fileName : SAMPLE_FILES) {
  26. TestResultsParser parser = new MSTestXmlTestResultsParser();
  27. parser.parse(BambooTestUtils.getInputStream(fileName));
  28. assertFalse(parser.getSuccessfulTests().isEmpty());
  29. }
  30. }
  31. @Test
  32. public void entriesWithSameName() throws Exception {
  33. TestResultsParser parser = new MSTestXmlTestResultsParser();
  34. parser.parse(BambooTestUtils.getInputStream(ENTRIES_WITH_SAME_NAME));
  35. assertFalse(parser.getSuccessfulTests().isEmpty());
  36. }
  37. @Test
  38. public void vs2010Format() throws Exception {
  39. TestResultsParser parser = new MSTestXmlTestResultsParser();
  40. parser.parse(BambooTestUtils.getInputStream(VS2010_Format));
  41. assertFalse(parser.getSuccessfulTests().isEmpty());
  42. }
  43. @Test
  44. public void vsKalamonFormat() throws Exception {
  45. TestResultsParser parser = new MSTestXmlTestResultsParser();
  46. parser.parse(BambooTestUtils.getInputStream(Kalamon_Format));
  47. assertFalse(parser.getSuccessfulTests().isEmpty());
  48. }
  49. @Test
  50. public void nant41() throws Exception {
  51. TestResultsParser parser = new MSTestXmlTestResultsParser();
  52. parser.parse(BambooTestUtils.getInputStream(NANT41));
  53. assertFalse(parser.getSuccessfulTests().isEmpty());
  54. }
  55. @Test
  56. public void regressionBSP3531() throws Exception
  57. {
  58. TestResultsParser parser = new MSTestXmlTestResultsParser();
  59. parser.parse(BambooTestUtils.getInputStream(BSP_3531_TRX, this.getClass()));
  60. assertEquals(230, parser.getSuccessfulTests().size());
  61. final TestResults testResults_0 = parser.getSuccessfulTests().get(0);
  62. assertEquals("Ident.ObjectModel.Tests.DataTypes.ApprovalFixture", testResults_0.getClassName());
  63. assertEquals("Approval test data factory validation", testResults_0.getMethodName());
  64. assertEquals("Approval_TestDataFactoryValidation", testResults_0.getActualMethodName());
  65. assertEquals(TestState.SUCCESS, testResults_0.getState());
  66. assertEquals("11.2608753", testResults_0.getDuration());
  67. assertEquals(11.2608753, testResults_0.getDurationInSeconds(), DELTA);
  68. }
  69. @Test
  70. public void regressionBSP5353() throws Exception
  71. {
  72. TestResultsParser parser = new MSTestXmlTestResultsParser();
  73. parser.parse(BambooTestUtils.getInputStream(BSP_5353_TRX, this.getClass()));
  74. assertEquals(19, parser.getFailedTests().size());
  75. }
  76. @Test
  77. public void inconclusiveTests() throws Exception {
  78. TestResultsParser parser = new MSTestXmlTestResultsParser();
  79. parser.parse(BambooTestUtils.getInputStream(NANT41));
  80. assertFalse(parser.getInconclusiveTests().isEmpty());
  81. }
  82. @Test
  83. public void errorTests() throws Exception {
  84. TestResultsParser parser = new MSTestXmlTestResultsParser();
  85. parser.parse(BambooTestUtils.getInputStream(VS2010_ERROR_TRX));
  86. assertEquals(1, parser.getSuccessfulTests().size());
  87. assertEquals(4, parser.getFailedTests().size());
  88. }
  89. }