Closed srosvall closed 4 years ago
What you want has always been directly supported in the mocking API. Check the API documentation for the result
field, and/or this Tutorial section.
Thanks. Missed that you could use multiple result assignments for a single expectation.
Hi, I am migrating to newer versions of Jmockit. Currently stuck on 1.35 as 1.36 removes StrictExpectations. This is a problem where we have a test for a method that shall handle exceptions from underlying (mocked) classes. The test has an expectation of two invocations of the mocked class, where the first will throw and the second will return a valid value.
With StrictExpectations I can express this with two result assignments. But with normal Expectations this does not work. And I cannot use returns() as it cannot be used with exceptions. (See https://github.com/jmockit/jmockit1/issues/178) I have attached an example below to illustrate the issue.
Please let me know how I can express that the first mocked call shall throw and the second return a valid value without using StrictExpectations. Thanks / Sven