|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.atinject.tck.Tck
public class Tck
Manufactures the compatibility test suite. This TCK relies on
JUnit. To integrate the TCK with your
injector, create a JUnit test suite class that passes an injected
Car
instance to testsFor(Car)
:
import junit.framework.Test; import org.atinject.tck.Tck; import org.atinject.tck.auto.Car; public class MyTck { public static Test suite() { Car car = new MyInjector().getInstance(Car.class); return Tck.testsFor(car, true /* supportsStatic */, true /* supportsPrivate */); } }
The static suite
method that returns a Test
is a JUnit
convention. Feel free to run the returned tests in other ways.
Configure the injector as follows:
Car
is implemented by
Convertible
.
@Drivers
Seat
is
implemented by DriversSeat
.
Seat
is
implemented by Seat
itself, and
Tire
by
Tire
itself
(not subclasses).
Engine
is implemented by
V8Engine
.
@Named("spare")
Tire
is implemented by
SpareTire
.
Cupholder
,
SpareTire
, and
FuelTank
.
Static and private member injection support is optional, but if your
injector supports those features, it must pass the respective tests. If
static member injection is supported, the static members of the following
types shall also be injected once:
Convertible
,
Tire
, and
SpareTire
.
Use your favorite JUnit tool to run the tests. For example, you can use your IDE or JUnit's command line runner:
java -cp javax.inject-tck.jar:junit.jar:myinjector.jar \ junit.textui.TestRunner MyTck
Method Summary | |
---|---|
static junit.framework.Test |
testsFor(Car car,
boolean supportsStatic,
boolean supportsPrivate)
Constructs a JUnit test suite for the given Car instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static junit.framework.Test testsFor(Car car, boolean supportsStatic, boolean supportsPrivate)
Car
instance.
car
- to testsupportsStatic
- true if the injector supports static member
injectionsupportsPrivate
- true if the injector supports private member
injection
java.lang.NullPointerException
- if car is null
java.lang.ClassCastException
- if car doesn't extend
Convertible
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |