Package junit.framework
Class JUnit4TestAdapter
- java.lang.Object
-
- junit.framework.JUnit4TestAdapter
-
- All Implemented Interfaces:
Test,Describable,Filterable,Orderable,Sortable
public class JUnit4TestAdapter extends java.lang.Object implements Test, Filterable, Orderable, Describable
The JUnit4TestAdapter enables running JUnit-4-style tests using a JUnit-3-style test runner.To use it, add the following to a test class:
public static Test suite() { return new JUnit4TestAdapter(YourJUnit4TestClass.class); }
-
-
Field Summary
Fields Modifier and Type Field Description private JUnit4TestAdapterCachefCacheprivate java.lang.Class<?>fNewTestClassprivate RunnerfRunner
-
Constructor Summary
Constructors Constructor Description JUnit4TestAdapter(java.lang.Class<?> newTestClass)JUnit4TestAdapter(java.lang.Class<?> newTestClass, JUnit4TestAdapterCache cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcountTestCases()Counts the number of test cases that will be run by this test.voidfilter(Filter filter)Remove tests that don't pass the parameterfilter.DescriptiongetDescription()java.lang.Class<?>getTestClass()java.util.List<Test>getTests()private booleanisIgnored(Description description)voidorder(Orderer orderer)Orders the tests usingordererprivate DescriptionremoveIgnored(Description description)voidrun(TestResult result)Runs a test and collects its result in a TestResult instance.voidsort(Sorter sorter)Sorts the tests usingsorterjava.lang.StringtoString()
-
-
-
Field Detail
-
fNewTestClass
private final java.lang.Class<?> fNewTestClass
-
fRunner
private final Runner fRunner
-
fCache
private final JUnit4TestAdapterCache fCache
-
-
Constructor Detail
-
JUnit4TestAdapter
public JUnit4TestAdapter(java.lang.Class<?> newTestClass)
-
JUnit4TestAdapter
public JUnit4TestAdapter(java.lang.Class<?> newTestClass, JUnit4TestAdapterCache cache)
-
-
Method Detail
-
countTestCases
public int countTestCases()
Description copied from interface:TestCounts the number of test cases that will be run by this test.- Specified by:
countTestCasesin interfaceTest
-
run
public void run(TestResult result)
Description copied from interface:TestRuns a test and collects its result in a TestResult instance.
-
getTests
public java.util.List<Test> getTests()
-
getTestClass
public java.lang.Class<?> getTestClass()
-
getDescription
public Description getDescription()
- Specified by:
getDescriptionin interfaceDescribable- Returns:
- a
Descriptionshowing the tests to be run by the receiver
-
removeIgnored
private Description removeIgnored(Description description)
-
isIgnored
private boolean isIgnored(Description description)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
filter
public void filter(Filter filter) throws NoTestsRemainException
Description copied from interface:FilterableRemove tests that don't pass the parameterfilter.- Specified by:
filterin interfaceFilterable- Parameters:
filter- theFilterto apply- Throws:
NoTestsRemainException- if all tests are filtered out
-
sort
public void sort(Sorter sorter)
Description copied from interface:SortableSorts the tests usingsorter
-
order
public void order(Orderer orderer) throws InvalidOrderingException
Orders the tests usingorderer- Specified by:
orderin interfaceOrderable- Throws:
InvalidOrderingException- if orderer does something invalid (like remove or add children)- Since:
- 4.13
-
-