001 /* 002 * Created on Mar 17, 2009 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 005 * in compliance with the License. You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software distributed under the License 010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 011 * or implied. See the License for the specific language governing permissions and limitations under 012 * the License. 013 * 014 * Copyright @2009 the original author or authors. 015 */ 016 package org.fest.swing.junit.runner; 017 018 import static org.fest.util.Files.currentFolder; 019 020 import java.io.File; 021 022 import org.fest.util.FilesException; 023 024 /** 025 * Understands creation of the folder where screenshots of failed GUI tests will be saved to. 026 * 027 * @author Alex Ruiz 028 */ 029 public class ImageFolderCreator { 030 031 private static final String FAILED_GUI_TESTS_FOLDER = "failed-gui-tests"; 032 033 private final FolderCreator folderCreator; 034 035 public ImageFolderCreator() { 036 this(new FolderCreator()); 037 } 038 039 ImageFolderCreator(FolderCreator folderCreator) { 040 this.folderCreator = folderCreator; 041 } 042 043 /** 044 * Creates the folder where to save screenshots of failing GUI tests. The name of the folder to create is 045 * 'failed-gui-tests'. If the folder already exists, it is deleted and recreated again. 046 * @return the created folder. 047 * @throws FilesException if any error occurs when creating the folder. 048 */ 049 public File createImageFolder() { 050 return folderCreator.createFolder(currentFolder(), FAILED_GUI_TESTS_FOLDER); 051 } 052 }