public class MethodRule extends Object implements org.junit.rules.MethodRule
MethodRule class provides a JUnit4 method rule which
enables additional useful functionalities for test cases.| Constructor and Description |
|---|
MethodRule(EConsumer<MethodRule,Exception>... handlers)
Instantiates a new
MethodRule object. |
| Modifier and Type | Method and Description |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runners.model.FrameworkMethod method,
Object target) |
int |
getLineNumber()
Gets the line number for the test method if available.
|
String |
getName()
Gets the name of the test method being executed.
|
String |
getSourceFile()
Gets the source file for the test method if available.
|
boolean |
hasTag(String tag)
Checks if the method is annotated with the specified tag.
|
MethodRule |
onFailure(EConsumer<Throwable,Exception> handler)
Register an error handler to be called on failure of the current test
case.
|
MethodRule |
onFailure(ERunnable<Exception> handler)
Register an error handler to be called on failure of the current test
case.
|
@SafeVarargs public MethodRule(EConsumer<MethodRule,Exception>... handlers)
MethodRule object.handlers - optional start handlers to invoke before the test case
startspublic org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
org.junit.runners.model.FrameworkMethod method,
Object target)
apply in interface org.junit.rules.MethodRuleMethodRule.apply(org.junit.runners.model.Statement, org.junit.runners.model.FrameworkMethod, java.lang.Object)public String getName()
public String getSourceFile()
null
if not availablepublic int getLineNumber()
-1 if not availablepublic boolean hasTag(String tag)
tag - the tag to check if the current test method is annotated withtrue if the test method is annotated with the
specified tag; false otherwiseTagpublic MethodRule onFailure(ERunnable<Exception> handler)
handler - the error handler to be called on failure of the test casepublic MethodRule onFailure(EConsumer<Throwable,Exception> handler)
handler - the error handler to be called on failure of the test caseCopyright (C) 2015-2017 The Helenus Driver Project Authors.