Using Mockwire with Junit

I primarily use Junit because I use Infinitest and Junit support in eclipse is a tad better than Testng.
Mockwire provides a junit4 runner: MockwireRunner to easily run your test all wired up.

@RunWith(MockwireRunner.class)
public class UnitTest {

 

Blessing and Mocking

@Bless and @Mock and mock are used to define the types that end up in the wire test environment.
Mockwire scans the test class and identitifies the code you wish to test. e.g. SomeConcreteClass in being tested so we need to bless a real instance of it. How the class is turned into a real instance is left up to the DI tool in use.

@Bless
SomeConcreteClass codeToTest;

And controlled dependencies of the code to test, e.g. SomeConcreteClass requires a SomeInterface, this requirement is defined by @Inject

@Mock
SomeInterface thatSomeConcreteClassNeeds;