Reputation: 167
For unit testing purpose i need to mock a method which take byte [] as argument.The output will be feed the argument. I want the output as per my requirement. So can anybody help me out with the mocking.
Upvotes: 0
Views: 155
Reputation: 16380
Use a Delegate
object when recording the expectation on the method with a byte[]
parameter. Here is an example:
@Test
public void someTestMethod(@Mocked final DependencyAbc abc)
{
new NonStrictExpectations() {{
abc.someMethod((byte[]) any);
result = new Delegate() {
byte[] delegate(byte[] b) { return b; }
};
}};
new UnitUnderTest(abc).doSomething();
}
Upvotes: 1