Java Reference
In-Depth Information
appendix B:
Extending the JUnit
API with custom
runners and matchers
This appendix covers
■
Introducing the Interceptor pattern
■
Implementing custom runners for JUnit
■
Implementing custom matchers for JUnit
As we already discussed in chapter 2, the backbone of
JU
nit consists of three
classes—
TestClass
,
Runner
, and
Suite
—the latter one being a
Runner
itself. This
means that once we understand how those classes operate, we can write whatever
tests we need with
JU
nit. If you find
JU
nit insufficient for your testing needs, you
can extend the
JU
nit
API
with custom classes. Since
JU
nit is open source you can
rebuild or extend. There is no obvious benefit in extending the
TestClass
class.
424