public class ProxyTestSuite
extends junit.framework.TestSuite
A simple wrapper around TestSuite
that permits the caller to specify
the delegate Test
for either directly or recursively contained
IProxyTest
s added to a ProxyTestSuite
. There are three cases
for junit:
TestCase
. If the class implements IProxyTest
then the
delegate will be set on the test instance and will be available when
that test runs.TestSuite.addTestSuite(java.lang.Class)
. That method scans the test
case class and generates an instantiated test for each conforming test method
identified in the test case. The delegate is then set per above.ProxyTestSuite
constructor will be flowed down to each test added either directly or
indirectly to that ProxyTestSuite
. The various constructors all
invoke this method to flow down the delegate. In addition, the
addTest(Test)
and addTestSuite(Class)
methods also
invoke this method to flow down the delegate to instantiated tests that
implement IProxyTest
.
The only case when flow down does not occur is when you have created a
standard test suite, addeded it to a proxy test suite, and then
you add additional tests to the standard test suite. There is no event
notification model in junit and this action is not noticed by the ProxyTestSuite
.
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
log
The
Logger is named for this class. |
Constructor and Description |
---|
ProxyTestSuite(junit.framework.Test delegate)
Creates an empty unnamed test suite.
|
ProxyTestSuite(junit.framework.Test delegate,
Class testClass)
Creates an unnamed test suite and populates it with test instances
identified by scanning the testClass .
|
ProxyTestSuite(junit.framework.Test delegate,
Class testClass,
String name)
Creates a named test suite and populates it with test instances
identified by scanning the testClass .
|
ProxyTestSuite(junit.framework.Test delegate,
String name)
Creates an empty named test suite.
|
Modifier and Type | Method and Description |
---|---|
void |
addTest(junit.framework.Test test)
If the suite is not a
ProxyTestSuite , then the tests in the
suite are recursively enumerated and a proxy test suite is created with
the same name and tests. |
void |
addTestSuite(Class testClass)
We override the implementation of
TestSuite.addTestSuite( Class theClass ) to wrap the
testClass in another instance of this ProxyTestSuite class using the same delegate that was provided
to our constructor. |
protected void |
flowDown(junit.framework.Test t) |
protected void |
flowDown(junit.framework.TestSuite suite)
Sets the delegate on each instantiated
Test that implements
IProxyTest . |
junit.framework.Test |
getDelegate()
Returns the delegate supplied to the constructor.
|
protected static final org.apache.log4j.Logger log
Logger
is named for this class.public ProxyTestSuite(junit.framework.Test delegate)
IProxyTest
.delegate
- The delegate (non-null).public ProxyTestSuite(junit.framework.Test delegate, Class testClass, String name)
IProxyTest
, including those created from testClass .delegate
- The delegate (non-null).testClass
- A class containing one or more tests.name
- The name of the test suite (optional).public ProxyTestSuite(junit.framework.Test delegate, Class testClass)
IProxyTest
, including those created from testClass .delegate
- The delegate (non-null).testClass
- A class containing one or more tests.public ProxyTestSuite(junit.framework.Test delegate, String name)
IProxyTest
.delegate
- The delegate (non-null).name
- The test suite name (optional).public junit.framework.Test getDelegate()
public void addTestSuite(Class testClass)
TestSuite.addTestSuite( Class theClass )
to wrap the
testClass in another instance of this ProxyTestSuite
class using the same delegate that was provided
to our constructor. This causes the delegation to be inherited
by any recursively contained testClass which implements
IProxyTest
.addTestSuite
in class junit.framework.TestSuite
public void addTest(junit.framework.Test test)
ProxyTestSuite
, then the tests in the
suite are recursively enumerated and a proxy test suite is created with
the same name and tests. This ensures that the common delegate flows down
through all tests even when using the traditional
static Test suite() {...}
construction.addTest
in class junit.framework.TestSuite
test
- A test.protected void flowDown(junit.framework.Test t)
protected void flowDown(junit.framework.TestSuite suite)
Sets the delegate on each instantiated Test
that implements
IProxyTest
.
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.