pending
pending copied to clipboard
JUnit rule to mark tests as pending. Tests marked as pending will not be evaluated.
Pending is an alternative to using @Ignore for bypassing tests that are failing due to the functionality not being implemented yet.
Pending provides is a JUnit rule and annotation for marking tests as pending. A pending test is expected to fail. Should the test pass the unexpected success will be reported.
Mark Tests As Pending with @PendingImplementation
Add the @PendingImplementation annotation to either a test class or method to mark tests as pending.
Example:
@PendingImplementation
public class MyTest {
@Rule public MethodRule pendingRule = new PendingRule();
/* Failing test methods */
...
}
public class MyTest {
@Rule public MethodRule pendingRule = new PendingRule();
@PendingImplementation
@Test public void
testMethod() {
/* Failing test */
...
}
}
The @Pending annotation takes an optional default parameter if you want to record why a test is marked as pending.
Example: Code: public class MyTest { @Rule public MethodRule pendingRule = PendingRule.withOutput();
@PendingImplementation("Work in progress")
@Test public void
testMethod() {
/* Failing test */
...
}
}
Mark Tests As Pending with JUnit @Category
Tests can be marked as pending with JUnit's @Category annotation.
Example:
@Category(PendingCategory.class)
public class MyTest {
@Rule public MethodRule pendingRule = new PendingRule(PendingCategory.class);
/* Failing test methods */
...
}
public class MyTest {
@Rule public MethodRule pendingRule = new PendingRule(PendingCategory.class);
@Category(PendingCategory.class)
@Test public void
testMethod() {
/* Failing test */
...
}
}