Examples of EasyMockTemplate


Examples of org.fest.mocks.EasyMockTemplate

  public void should_take_screenshot_when_test_fails() {
    final ScreenshotXmlWriter writer = createMock(ScreenshotXmlWriter.class);
    updateWriterInFormatter(writer);
    final junit.framework.Test test = failingTest();
    final XmlNode errorElement = createMock(XmlNode.class);
    new EasyMockTemplate(writer) {
      @Override protected void expectations() {
        writer.writeScreenshot(errorElement, test);
        expectLastCall().once();
      }
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

  @Test
  public void should_add_test_node_as_child() {
    final TestStub test = new TestStub("hello");
    final XmlNode newNode = mockXmlNode();
    new EasyMockTemplate(targetNode) {
      @Override protected void expectations() {
        XmlAttributes attributes = attributes(name(ATTR_NAME).value("hello"),
                                              name(ATTR_CLASSNAME).value(TestStub.class.getName()));
        expect(targetNode.addNewNode(TESTCASE, attributes)).andReturn(newNode);
      }
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

  @Test
  public void should_add_test_node_as_child_and_set_test_name_to_unknown_if_test_name_is_null() {
    final TestStub test = new TestStub(null);
    final XmlNode newNode = mockXmlNode();
    new EasyMockTemplate(targetNode) {
      @Override protected void expectations() {
        XmlAttributes attributes = attributes(name(ATTR_NAME).value("unknown"),
                                              name(ATTR_CLASSNAME).value(TestStub.class.getName()));
        expect(targetNode.addNewNode(TESTCASE, attributes)).andReturn(newNode);
      }
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

  @Test
  public void should_not_close_OutputStream_when_using_SystemOut_or_SystemErr() {
    final StandardOutputStreams streams = createMock(StandardOutputStreams.class);
    writer = new XmlOutputWriter(streams);
    final MyOutputStream out = new MyOutputStream();
    new EasyMockTemplate(streams) {
      @Override protected void expectations() {
        expect(streams.isStandardOutOrErr(out)).andReturn(true);
      }

      @Override protected void codeToTest() throws Exception {
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

    path = "somePath";
  }

  @Test
  public void should_not_rethrow_error() {
    new EasyMockTemplate(decoder, writer) {
      @Override protected void expectations() throws Throwable {
        expect(decoder.decodeBase64(encoded)).andReturn(image);
        writer.writeAsPng(image, path);
        expectLastCall().andThrow(thrownOnPurpose());
      }
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

public class EnvironmentXmlNodeWriter_writeHostName_Test extends EnvironmentXmlNodeWriter_TestCase {

  @Test
  public void should_write_host_name_as_attribute() {
    final String hostName = "myHost";
    new EasyMockTemplate(timeStampFormatter, hostNameReader, targetNode) {
      @Override protected void expectations() throws Exception {
        expect(hostNameReader.localHostName()).andReturn(hostName);
        targetNode.addAttribute(name(HOSTNAME).value(hostName));
        expectLastCall().once();
      }
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

  }

  @Test
  public void should_write_local_host_as_attribute_if_host_name_could_not_be_obtained() {
    final UnknownHostException e = new UnknownHostException();
    new EasyMockTemplate(timeStampFormatter, hostNameReader, targetNode) {
      @Override protected void expectations() throws Exception {
        expect(hostNameReader.localHostName()).andThrow(e);
        targetNode.addAttribute(name(HOSTNAME).value("localhost"));
        expectLastCall().once();
      }
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

    image = mockImage();
  }

  @Test
  public void should_not_rethrow_error() {
    new EasyMockTemplate(encoder) {
      @Override protected void expectations() throws Throwable {
        expect(encoder.encodeBase64(image)).andThrow(thrownOnPurpose());
      }

      @Override protected void codeToTest() {
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

    reportMatcher(new BeforeOrEqualDateMatcher(date));
  }

  @Test
  public void shouldWriteFormattedCurrentDateAsAttribute() {
    new EasyMockTemplate(timeStampFormatter, hostNameReader, targetNode) {
      @Override protected void expectations() {
        expect(timeStampFormatter.format(date)).andReturn(formatted);
        targetNode.addAttribute(XmlAttribute.name(TIMESTAMP).value(formatted));
        expectLastCall().once();
      }
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

  public void shouldWriteStackTraceAsTextNode() {
    final Exception error = new Exception();
    final StackTraceFilter filter = createMock(StackTraceFilter.class);
    writer = new TestXmlNodeWriter(filter);
    new EasyMockTemplate(filter, targetNode) {
      @Override protected void expectations() {
        expect(filter.filter(error)).andReturn("Hello");
        targetNode.addText("Hello");
        expectLastCall().once();
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.