This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Patrick Huang
committed
Jan 7, 2014
1 parent
fc7f6df
commit 45457d9
Showing
5 changed files
with
86 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
functional-test/src/test/java/org/zanata/util/TakeScreenshotRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.zanata.util; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Date; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.io.FileUtils; | ||
import org.junit.rules.ExternalResource; | ||
import org.junit.runner.Description; | ||
import org.junit.runners.model.Statement; | ||
import org.zanata.page.WebDriverFactory; | ||
|
||
/** | ||
* @author Patrick Huang <a | ||
* href="mailto:pahuang@redhat.com">pahuang@redhat.com</a> | ||
*/ | ||
@Slf4j | ||
public class TakeScreenshotRule extends ExternalResource { | ||
|
||
private String testDisplayName; | ||
|
||
@Override | ||
public Statement apply(Statement base, Description description) { | ||
testDisplayName = description.getDisplayName(); | ||
return super.apply(base, description); | ||
} | ||
|
||
@Override | ||
protected void before() throws Throwable { | ||
super.before(); | ||
WebDriverFactory.INSTANCE.updateListenerTestName(testDisplayName); | ||
String date = new Date().toString(); | ||
log.debug("[TEST] {}:{}", testDisplayName, date); | ||
} | ||
|
||
@Override | ||
protected void after() { | ||
super.after(); | ||
File baseDir = new File(WebDriverFactory.getScreenshotBaseDir()); | ||
try { | ||
FileUtils.deleteDirectory(baseDir); | ||
} | ||
catch (IOException e) { | ||
log.warn("error deleting screenshot base directory: {}", | ||
e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters