Package org.fest.swing.junit.xml

Examples of org.fest.swing.junit.xml.XmlNode


    assertThat(actual).isEqualTo(expectedXml());
    assertThat(out.closed).isFalse();
  }

  private XmlNode xml() throws Exception {
    XmlNode root = new XmlDocument().newRoot("root");
    root.addNewNode("child");
    return root;
  }
View Full Code Here


*/
public class TestXmlNodeWriter_writeTestExecutionTime_Test extends TestXmlNodeWriter_TestCase {

  @Test
  public void should_add_test_execution_time_as_attribute() {
    XmlNode root = new XmlDocument().newRoot("root");
    assertThat(writer.writeTestExecutionTime(root, currentTimeMillis() - 3000)).isSameAs(writer);
    double time = parseDouble(root.valueOfAttribute(ATTR_TIME));
    assertThat(time).isGreaterThan(0d);
  }
View Full Code Here

  public void should_write_test_execution_when_test_fails() {
    startSuite();
    junit.framework.Test test = mockTest();
    AssertionFailedError error = errorOrFailure();
    formatter.addFailure(test, error);
    XmlNode root = root();
    assertThatTestCaseNodeWasAddedTo(root);
    XmlNode failureNode = firstTestCaseNodeIn(root).child(0);
    assertThat(failureNode.name()).isEqualTo("failure");
    assertThatErrorOrFailureWasWrittenTo(failureNode);
    assertThat(formatter.onFailureOrErrorMethod).wasCalledPassing(test, error, failureNode);
  }
View Full Code Here

  public void should_write_test_execution_when_error_is_thrown() {
    startSuite();
    junit.framework.Test test = mockTest();
    AssertionFailedError error = errorOrFailure();
    formatter.addError(test, error);
    XmlNode root = root();
    assertThatTestCaseNodeWasAddedTo(root);
    XmlNode errorNode = firstTestCaseNodeIn(root).child(0);
    assertThat(errorNode.name()).isEqualTo("error");
    assertThatErrorOrFailureWasWrittenTo(errorNode);
    assertThat(formatter.onFailureOrErrorMethod).wasCalledPassing(test, error, errorNode);
  }
View Full Code Here

  }

  @Test
  public void should_write_suite_and_environment_info() {
    formatter.startTestSuite(suite);
    XmlNode root = root();
    assertThat(root.attributeCount()).isEqualTo(3);
    assertThatSuiteAndEnvironmentInfoWereAddedTo(root);
    assertThatThereAreNoPropertiesIn(root);
  }
View Full Code Here

  }

  void onSetUp() {}

  static void assertThatThereAreNoPropertiesIn(XmlNode root) {
    XmlNode properties = root.child(0);
    assertThat(properties.attributeCount()).isEqualTo(0);
    assertThat(properties.size()).isEqualTo(0);
  }
View Full Code Here

  final XmlNode root() {
    return formatter.xmlRootNode();
  }

  final void assertThatTestCaseNodeWasAddedTo(XmlNode root) {
    XmlNode testNode = firstTestCaseNodeIn(root);
    assertThat(testNode.name()).isEqualTo("testcase");
    assertThat(testNode.valueOfAttribute("classname")).startsWith("$Proxy");
    assertThat(testNode.valueOfAttribute("name")).isEqualTo("unknown");
    double executionTime = Double.parseDouble(testNode.valueOfAttribute("time"));
    assertThat(executionTime).isGreaterThanOrEqualTo(0d);
  }
View Full Code Here

      informCannotTakeScreenshots(e);
    }
  }

  private void informCannotTakeScreenshots(ImageException error) {
    XmlNode errorNode = xmlRootNode().addNewNode(ERROR);
    writeErrorAndStackTrace(error, errorNode);
  }
View Full Code Here

    BufferedImage image = screenshotTaker.takeDesktopScreenshot();
    return encodeBase64(image);
  }

  private void writeScreenshotFileName(XmlNode target, String encodedImage, String imageFileName) {
    XmlNode screenshotNode = target.parentNode().addNewNode(SCREENSHOT_ELEMENT);
    screenshotNode.addAttribute(name(SCREENSHOT_FILE_ATTRIBUTE).value(imageFileName));
    screenshotNode.addText(encodedImage);
  }
View Full Code Here

   * A test is finished.
   * @param test the test.
   */
  public final void endTest(Test test) {
    if (!tests.wasStarted(test)) startTest(test);
    XmlNode testNode = xmlNodeForFinished(test);
    testXmlNodeWriter.writeTestExecutionTime(testNode, tests.startTimeOf(test));
  }
View Full Code Here

TOP

Related Classes of org.fest.swing.junit.xml.XmlNode

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.