I’m looking for something similar to the structuremap or eleution automocking containers in the .NET world
I’m looking for something similar to the structuremap or eleution automocking containers in the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, for Java there is the Unitils Mock library, which provides
@TestedObjectand@InjectInto...annotations for automatic injection of declarative mocks into tested objects.Another option is JMockit, but it currently does not automatically inject its mocks into tested objects. OTOH, it does create mock objects declaratively, assigning them to instance fields or passing them as test method arguments; so, there is no “createMock” method.
The use of DI is important for mocking APIs such as Unitils Mock, EasyMock, jMock, and Mockito, because they always require mock instances to be passed to code under test. With JMockit, though, DI can be used just the same, but is unnecessary since instances created internally by code under test will get mocked transparently.