Examples of EasyMockTemplate


Examples of org.fest.mocks.EasyMockTemplate

  @Test
  public void should_throw_Exception_in_case_of_error() {
    final File f = createMock(File.class);
    final RuntimeException error = new RuntimeException();
    new EasyMockTemplate(f) {
      @Override protected void expectations() throws Exception {
        EasyMock.expect(f.getCanonicalPath()).andThrow(error);
      }

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

Examples of org.fest.mocks.EasyMockTemplate

    properties.setProperty("key1", "value1");
    properties.setProperty("key2", "value2");
    final JUnitTest suite = new JUnitTest("Hello");
    suite.setProperties(properties);
    final XmlNode propertiesNode = mockXmlNode();
    new EasyMockTemplate(targetNode, propertiesNode) {
      @Override protected void expectations() throws Exception {
        expect(targetNode.addNewNode(PROPERTIES)).andReturn(propertiesNode);
        XmlAttributes attributes1 = attributes(name(ATTR_NAME).value("key1"), name(ATTR_VALUE).value("value1"));
        expect(propertiesNode.addNewNode(PROPERTY, attributes1)).andReturn(mockXmlNode());
        XmlAttributes attributes2 = attributes(name(ATTR_NAME).value("key2"), name(ATTR_VALUE).value("value2"));
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

  }

  @Test
  public void should_create_image_folder() {
    final File createdFolder = new File("fake");
    new EasyMockTemplate(folderCreator) {
      @Override protected void expectations() {
        expect(folderCreator.createFolder(currentFolder(), "failed-gui-tests")).andReturn(createdFolder);
      }

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

Examples of org.fest.mocks.EasyMockTemplate

  public void shouldNotAddPropertiesIfPropertiesIsNull() {
    final JUnitTest suite = new JUnitTest("Hello");
    assertThat(suite.getProperties()).isNull();
    final XmlNode propertiesNode = mockXmlNode();
    new EasyMockTemplate(targetNode, propertiesNode) {
      @Override protected void expectations() throws Exception {
        expect(targetNode.addNewNode(PROPERTIES)).andReturn(propertiesNode);
      }

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

Examples of org.fest.mocks.EasyMockTemplate

  public void shouldNotAddPropertiesIfPropertiesIsEmpty() {
    final JUnitTest suite = new JUnitTest("Hello");
    suite.setProperties(new Properties());
    assertThat(suite.getProperties()).isEmpty();
    final XmlNode propertiesNode = mockXmlNode();
    new EasyMockTemplate(targetNode, propertiesNode) {
      @Override protected void expectations() throws Exception {
        expect(targetNode.addNewNode(PROPERTIES)).andReturn(propertiesNode);
      }

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

Examples of org.fest.mocks.EasyMockTemplate

  public void shouldWriteStatisticsAsAttribute() {
    final JUnitTest suite = new JUnitTest("Hello");
    suite.setCounts(6l, 2l, 1l);
    suite.setRunTime(8000l);
    new EasyMockTemplate(targetNode) {
      @Override protected void expectations() {
        expectAttributeAdded(name(ATTR_TESTS).value(6l));
        expectAttributeAdded(name(ATTR_FAILURES).value(2l));
        expectAttributeAdded(name(ATTR_ERRORS).value(1l));
        expectAttributeAdded(name(ATTR_TIME).value(8.0));
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

    failureScreenshotTaker = new FailureScreenshotTaker(imageFolder, screenshotTaker);
  }

  @Test
  public void should_save_screenshot_with_given_test_name_at_given_folder() {
    new EasyMockTemplate(screenshotTaker, imageFolder) {
      @Override protected void expectations() throws Exception {
        expect(imageFolder.getCanonicalPath()).andReturn("myPath");
        screenshotTaker.saveDesktopAsPng(concat("myPath", separator, "testName.png"));
        expectLastCall().once();
      }
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

    }.run();
  }

  @Test
  public void should_not_rethrow_Exceptions() {
    new EasyMockTemplate(screenshotTaker, imageFolder) {
      @Override protected void expectations() throws Exception {
        expect(imageFolder.getCanonicalPath()).andThrow(new IOException("Thrown on purpose"));
      }

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

Examples of org.fest.mocks.EasyMockTemplate

public class SuiteXmlNodeWriter_writeSuiteName_Test extends SuiteXmlNodeWriter_TestCase {

  @Test
  public void should_write_suite_name_as_attribute() {
    final JUnitTest suite = new JUnitTest("Hello");
    new EasyMockTemplate(targetNode) {
      @Override protected void expectations() throws Exception {
        targetNode.addAttribute(name(ATTR_NAME).value("Hello"));
        expectLastCall().once();
      }
View Full Code Here

Examples of org.fest.mocks.EasyMockTemplate

  }

  @Test
  public void should_write_word_unknown_as_attribute_if_suite_does_not_have_name() {
    final JUnitTest suite = new JUnitTest(null);
    new EasyMockTemplate(targetNode) {
      @Override protected void expectations() throws Exception {
        targetNode.addAttribute(name(ATTR_NAME).value("unknown"));
      }

      @Override protected void codeToTest() {
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.