Package com.puppetlabs.geppetto.junitresult

Examples of com.puppetlabs.geppetto.junitresult.Testsuite


  public void testLoad_Bougie_testsuite() throws IOException {
    File f = TestDataProvider.getTestFile(new Path("testData/BougieTest_testsuite.xml"));
    JunitResult result = JunitresultLoader.loadFromXML(f);

    assertTrue("should be a Testsuite instance", result instanceof Testsuite);
    Testsuite rootsuite = (Testsuite) result;
    assertEquals("net.cars.engine.BougieTest", rootsuite.getName());
    assertEquals(2, rootsuite.getTests());
    assertEquals(0, rootsuite.getFailures());
    assertEquals(1, rootsuite.getErrors());
    assertEquals("hazelnut.osuosl.org", rootsuite.getHostname());
    Calendar calendar = javax.xml.bind.DatatypeConverter.parseDateTime("2007-11-02T23:13:50");
    Date expected = calendar.getTime();

    assertEquals(expected, rootsuite.getTimestamp());

    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());
View Full Code Here


  public void testLoad_CarborateurTest() throws IOException {
    File f = TestDataProvider.getTestFile(new Path("testData/CarborateurTest_testsuite.xml"));
    JunitResult result = JunitresultLoader.loadFromXML(f);
    assertTrue("should be a Testsuite instance", result instanceof Testsuite);
    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());
View Full Code Here

  public void testLoad_DelcoTest() throws IOException {
    File f = TestDataProvider.getTestFile(new Path("testData/DelcoTest_testsuite.xml"));
    JunitResult result = JunitresultLoader.loadFromXML(f);
    assertTrue("should be a Testsuite instance", result instanceof Testsuite);
    Testsuite rootsuite = (Testsuite) result;
    assertEquals("net.cars.engine.DelcoTest", rootsuite.getName());

    assertEquals("Rotation is simulated for a four spark engine with an angle of 0?.\n", rootsuite.getSystem_out());
    assertEquals("TestText", rootsuite.getSystem_err());
  }
View Full Code Here

    assertEquals(0, testrun.getFailures());
    assertEquals(1, testrun.getErrors());
    assertEquals(0, testrun.getIgnored());

    assertEquals("There should be one testsuite", 1, testrun.getTestsuites().size());
    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());
View Full Code Here

   */
  @Override
  protected T doSwitch(int classifierID, EObject theEObject) {
    switch(classifierID) {
      case JunitresultPackage.TESTSUITE: {
        Testsuite testsuite = (Testsuite) theEObject;
        T result = caseTestsuite(testsuite);
        if(result == null)
          result = caseAbstractAggregatedTest(testsuite);
        if(result == null)
          result = caseJunitResult(testsuite);
View Full Code Here

   * @param element
   * @param extendedForm
   * @return
   */
  private Testsuite loadTestSuite(Element element, boolean extendedForm) {
    Testsuite o = JunitresultFactory.eINSTANCE.createTestsuite();
    // super class part
    loadAbstractAggregatedPart(o, element);

    // attributes
    o.setSystem_err(getTagValue(element, "system-err"));
    o.setSystem_out(getTagValue(element, "system-out"));
    o.setHostname(element.getAttribute("hostname"));
    o.setTime(getTime(element, "time"));
    o.setTimestamp(getTimestamp(element, "timestamp"));

    // JUnit 4 - (?)
    o.setDisabled(getIntAttributeWith0Default(element, "disabled"));
    o.setSkipped(getIntAttributeWith0Default(element, "skipped"));

    // when embedded in a junitreport result where <testsuites> is the document root these two
    // attributes are present in each nested testsuite.
    //
    if(extendedForm) {
      o.setId(getIntAttributeWith0Default(element, "id"));
      o.setPackage(element.getAttribute("package"));
    }

    // child test suites (nested) & test cases
    NodeList children = element.getChildNodes();
    for(int i = 0; i < children.getLength(); i++) {
      Node n = children.item(i);
      if(n.getNodeType() == Node.ELEMENT_NODE)
        if("testsuite".equalsIgnoreCase(n.getNodeName()))
          o.getTestsuites().add(loadTestSuite((Element) n, extendedForm));
        else if("testcase".equalsIgnoreCase(n.getNodeName()))
          o.getTestcases().add(loadTestCase((Element) n));
        else if("properties".equalsIgnoreCase(n.getNodeName())) {
          NodeList properties = ((Element) n).getElementsByTagName("property");
          for(int j = 0; j < properties.getLength(); j++) {
            Node pn = properties.item(j);
            if(pn.getNodeType() == Node.ELEMENT_NODE) {
              Element propertyElement = (Element) pn;
              Property p = JunitresultFactory.eINSTANCE.createProperty();
              p.setName(propertyElement.getAttribute("name"));
              p.setValue(propertyElement.getAttribute("value"));
              o.getProperties().add(p);
            }
          }
        }
    }

View Full Code Here

    testsuites.setName(relative.toString());
    return testsuites;
  }

  private Testsuite createSuite(File reportDir) {
    Testsuite testsuite = JunitresultFactory.eINSTANCE.createTestsuite();
    testsuite.setName(reportDir.getName());
    return testsuite;
  }
View Full Code Here

    for(File f : root.listFiles(xmlFileFilter))
      if(!isSymlink(f))
        processXMLFile(parent, f);
    for(File d : root.listFiles(directoryFilter))
      if(!isSymlink(d)) {
        Testsuite dirSuite = createSuite(d);
        parent.getTestsuites().add(dirSuite);
        processFiles(dirSuite, d);
      }
  }
View Full Code Here

   *
   * @param f
   * @param testrun
   */
  private void processTestrun(AbstractAggregatedTest parent, File f, Testrun testrun) {
    Testsuite containerSuite = JunitresultFactory.eINSTANCE.createTestsuite();
    containerSuite.setName(suitename(f));
    containerSuite.getTestsuites().addAll(testrun.getTestsuites());
    parent.getTestsuites().add(containerSuite);
  }
View Full Code Here

    // Is this a testsuite with testcases where testcases have a classname that is a reference to
    // a .rb spec file?
    if(isExtraRspecFormatterStyle(testsuite)) {
      // create a new testsuite to act as the container for all contained (computed suites).
      // this container is named after the path/file
      Testsuite containerSuite = JunitresultFactory.eINSTANCE.createTestsuite();
      containerSuite.setName(suitename(f));
      containerSuite.setTimestamp(timestamp);

      // create one suite per source classname and add test cases belonging to that suite
      Multimap<String, Testcase> map = ArrayListMultimap.create();
      for(Testcase tc : testsuite.getTestcases()) {
        String key = tc.getClassname();
        if(key == null || key.length() == 0 || !key.endsWith(".rb"))
          key = "unspecified-source";
        map.put(key, tc);
      }
      for(String key : map.keySet()) {
        Testsuite suitePerClass = JunitresultFactory.eINSTANCE.createTestsuite();
        // suite name is classname without leading ./ and trailing .rb
        String suitename = key.substring(key.startsWith("./")
            ? 2
            : 0, //
          key.length() - (key.endsWith(".rb")
              ? 3
              : 0));
        suitePerClass.setName(suitename);
        suitePerClass.setTimestamp(timestamp);

        // add all testcases from the same source (i.e. same "classname")
        suitePerClass.getTestcases().addAll(map.get(key));
        containerSuite.getTestsuites().add(suitePerClass);
      }
      parent.getTestsuites().add(containerSuite);
      // all work done
    }
View Full Code Here

TOP

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

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.