public class ResourceHelper extends TestFailureAwareRule
Selenium can upload only File instances (See FileDetector).
In tests you might want to upload a file, which is inside a JAR file you are having on the classpath.
This rule can copy such resources into a temp file, which will be then available during the test for being uploaded.
After the test the cleanup of such files happens automatically.
See also FileDetectorConfigurator.
| Constructor and Description |
|---|
ResourceHelper() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
after(org.junit.runner.Description description,
Throwable testFailure)
Called after all tests always.
|
protected void |
before(org.junit.runner.Description description)
Can do something before a test.
|
File |
getResourceAsFile(String resourcePath)
Gets resource either from a jar or from a file as stream, and writes its content into a temp file.
|
apply, onErrorprotected void before(org.junit.runner.Description description)
throws Throwable
TestFailureAwareRulebefore in class TestFailureAwareRuledescription - junit test description objectThrowable - any error from the testprotected void after(org.junit.runner.Description description,
Throwable testFailure)
throws Throwable
TestFailureAwareRuleafter in class TestFailureAwareRuledescription - junit test description objecttestFailure - in case of failed test it contains an exception. Otherwise nullThrowable - if testFailure is null, it will fly, if testFailure is not null,
it will be added to that as suppressed exception. See Throwable.addSuppressed(Throwable)public File getResourceAsFile(String resourcePath)
resourcePath - classpath resource pathCopyright © 2017 willhaben internet service GmbH & Co KG. All rights reserved.