Package com.puppetlabs.geppetto.junitresult

Examples of com.puppetlabs.geppetto.junitresult.Testcase


    Testsuite testsuite = rootsuite;
    assertEquals("net.cars.engine.BougieTest", testsuite.getName());
    assertEquals(0.017, testsuite.getTime());

    assertEquals("There should be two testcases", 2, testsuite.getTestcases().size());
    Testcase tc1 = testsuite.getTestcases().get(0);
    Testcase tc2 = testsuite.getTestcases().get(1);

    assertEquals("sparkDry", tc1.getName());
    assertEquals("net.cars.engine.BougieTest", tc1.getClassname());
    assertEquals(0.0010, tc1.getTime());

    assertEquals("sparkHumid", tc2.getName());
    assertEquals("net.cars.engine.BougieTest", tc2.getClassname());
    assertEquals(0.0050, tc2.getTime());

    assertEquals(1, tc2.getErrors().size());
    NegativeResult error = tc2.getErrors().get(0);
    assertTrue(error instanceof com.puppetlabs.geppetto.junitresult.Error);
    assertEquals("java.lang.RuntimeException: humidity level too high\n" + //
        "\tat net.cars.engine.Bougie.spark(Unknown Source)\n" + //
        "\tat net.cars.engine.BougieTest.sparkHumid(BougieTest.java:36)\n", error.getValue());
View Full Code Here


    Testsuite rootsuite = (Testsuite) result;
    assertEquals("net.cars.engine.CarburateurTest", rootsuite.getName());

    // should have one testcase with a failure
    assertEquals("There should be one testcase", 1, rootsuite.getTestcases().size());
    Testcase tc = rootsuite.getTestcases().get(0);
    assertEquals(1, tc.getFailures().size());
    NegativeResult failure = tc.getFailures().get(0);
    assertNotNull(failure);
    assertTrue(failure instanceof Failure);
    assertEquals("Mix should be exactly 25. expected:<25> but was:<20>", failure.getMessage());
    assertEquals("junit.framework.AssertionFailedError: Mix should be exactly 25. expected:<25> but was:<20>\n" + //
        "\tat net.cars.engine.CarburateurTest.mix(CarburateurTest.java:34)\n", failure.getValue());
View Full Code Here

    Testsuite testsuite = testrun.getTestsuites().get(0);
    assertEquals("net.cars.engine.BougieTest", testsuite.getName());
    assertEquals(0.017, testsuite.getTime());

    assertEquals("There should be two testcases", 2, testsuite.getTestcases().size());
    Testcase tc1 = testsuite.getTestcases().get(0);
    Testcase tc2 = testsuite.getTestcases().get(1);

    assertEquals("sparkDry", tc1.getName());
    assertEquals("net.cars.engine.BougieTest", tc1.getClassname());
    assertEquals(0.001, tc1.getTime());

    assertEquals("sparkHumid", tc2.getName());
    assertEquals("net.cars.engine.BougieTest", tc2.getClassname());
    assertEquals(0.005, tc2.getTime());

    assertEquals(1, tc2.getErrors().size());
    NegativeResult error = tc2.getErrors().get(0);
    assertTrue(error instanceof com.puppetlabs.geppetto.junitresult.Error);
    assertEquals("java.lang.RuntimeException: humidity level too high\n" + //
        "\tat net.cars.engine.Bougie.spark(Unknown Source)\n" + //
        "\tat net.cars.engine.BougieTest.sparkHumid(BougieTest.java:36)\n", error.getValue());
View Full Code Here

        if(result == null)
          result = defaultCase(theEObject);
        return result;
      }
      case JunitresultPackage.TESTCASE: {
        Testcase testcase = (Testcase) theEObject;
        T result = caseTestcase(testcase);
        if(result == null)
          result = defaultCase(theEObject);
        return result;
      }
View Full Code Here

  }

  private Testcase loadTestCase(Element element) {
    if(!"testcase".equalsIgnoreCase(element.getNodeName()))
      throw new IllegalArgumentException("Non 'testcase' element passed to #loadTestCase");
    Testcase o = JunitresultFactory.eINSTANCE.createTestcase();

    o.setClassname(element.getAttribute("classname"));
    o.setName(element.getAttribute("name"));
    o.setTime(getTime(element, "time"));

    // Only one of these are allowed - error, failure, skipped
    // let the last win

    // Error element
    NodeList errors = element.getElementsByTagName("error");
    for(int i = 0; i < errors.getLength(); i++) {
      Error error = JunitresultFactory.eINSTANCE.createError();
      loadNegativeResult(error, errors);
      o.getErrors().add(error);
    }

    // Failure element
    NodeList failures = element.getElementsByTagName("failure");
    for(int i = 0; i < failures.getLength(); i++) {
      Failure failure = JunitresultFactory.eINSTANCE.createFailure();
      loadNegativeResult(failure, failures);
      o.getFailures().add(failure);
    }

    // Skipped element
    NodeList skipps = element.getElementsByTagName("skipped");
    if(skipps.getLength() > 0) {
      Skipped skipped = JunitresultFactory.eINSTANCE.createSkipped();
      loadNegativeResult(skipped, skipps);
      o.setSkipped(skipped);
    }

    o.getSystem_err().addAll(getTagValues(element, "system-err"));
    o.getSystem_out().addAll(getTagValues(element, "system-out"));
    return o;

  }
View Full Code Here

      loadExceptionSuite = JunitresultFactory.eINSTANCE.createTestsuite();
      loadExceptionSuite.setName("Exceptions computing aggregated testresult");
      loadExceptionSuite.setTimestamp(new Date());
      rootSuite.getTestsuites().add(loadExceptionSuite);
    }
    Testcase tc = JunitresultFactory.eINSTANCE.createTestcase();
    tc.setName("Error loading: " + f.getAbsolutePath());

    Error error = JunitresultFactory.eINSTANCE.createError();
    StringBuilder builder = new StringBuilder();
    builder.append("Can not load junit xml result from file: ").append(f.getAbsolutePath()).append("\n");
    builder.append("Caused by: ").append(e.toString());
    error.setValue(builder.toString());
    error.setMessage(e.getMessage());

    tc.getErrors().add(error);
    loadExceptionSuite.getTestcases().add(tc);
  }
View Full Code Here

  private boolean isSuiteWrappingSingleCase(Testsuite testsuite) {
    EList<Testcase> tcs = testsuite.getTestcases();
    if(tcs.size() != 1)
      return false;
    Testcase tc = tcs.get(0);
    String tsname = testsuite.getName();
    String tcname = tc.getName();
    if(tsname == null || tcname == null)
      return false;
    return tsname.equals(tcname);
  }
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.junitresult.Testcase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.