concept Mycila in category java

This is an excerpt from Manning's book JUnit in Action, Second Edition.
Mycila (http://code.google.com/p/mycila) is an umbrella for many subprojects, each one focused on particular needs, such as testing. It’s the latest offspring of this new breed of general-purpose testing libraries (which also includes Unitils and FEST), and at the time this chapter was written it was still in its infancy. Although all of its features we analyze in this chapter are provided by other tools, this project also offers unique features, such as a module to test Guice[3] -based applications; if it fulfills its ambitious goal of providing “Powerful projects for everyday needs!” it could be another valuable asset in the toolbox.
Mycila mock support is similar to Unitils in the way that you mark your mock attributes with annotations. Unlike Unitils, however, you still need to do some manual setup in a @Before method, such as creating the objects being tested and calling the Mycila initialization method. Listing 19.3 shows our example converted to Mycila.
As you can see on
, Mycila doesn’t require any special inheritance or custom runner, which forces the test case to explicitly call its TestSetup.setup() in a @Before method
. That method then scans the test class looking for @Mock annotations and does the proper EasyMock setup when they’re found, such as in
. Notice that each test case statement that requires a reference to these mocks (like the dependency injection defined in
) must be executed after TestSetup.setup() is called. Mock injection is the only mock support Mycila provides; the test method itself
is responsible for calling replay() and verify() in the mocks.
Mycila also supports other mock frameworks, such as JMock (also analyzed in chapter 6) and Mockito (http://mockito.org). Listing 19.4 shows the same example using the JMock plug-in.
Mycila also provides a module for assertions, which uses a Hamcrest-like style similar to FEST, as shown in the examples at the project’s wiki page (http://code.google.com/p/mycila/wiki/ExtendedAssertions). Unfortunately though, this module was not widely available at the time the book was written, so we had to skip it. But it’s a project that’s worth watching.
, Mycila doesn’t require any special inheritance or custom runner, which forces the test case to explicitly call its TestSetup.setup() in a @Before method
. That method then scans the test class looking for @Mock annotations and does the proper EasyMock setup when they’re found, such as in
. Notice that each test case statement that requires a reference to these mocks (like the dependency injection defined in
) must be executed after TestSetup.setup() is called. Mock injection is the only mock support Mycila provides; the test method itself
is responsible for calling replay() and verify() in the mocks.