Support for Answers in mock setup
See original GitHub issueIt would be very useful to be able to do a doAnswer
in the same way as a doReturn
or a doThrow
. Something like:
private val userDao: UserDao = mock {
on(this.save(any())) doAnswer { user ->
UserModel(id = "userId", version = 1L, userData = user)
}
}
At the moment I’m having to do this in an @Before or else in each test case.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:15
Top Results From Across the Web
c# - Moq: How to get to a parameter passed to a method of a ...
You can use the Mock.Callback-method: var mock = new Mock<Handler>(); SomeResponse result = null; mock.Setup(h => h.AsyncHandle(It.IsAny<SomeResponse>())) .
Read more >How YOU can Learn Mock testing in .NET Core and C# with ...
This will teach you how to do Mock testing in .NET Core and C# with the library Moq.
Read more >Service Mocking Overview | REST Mocking - SoapUI
The REST service mocking feature allows you to simulate a REST service by creating a mock service. You can then run it either...
Read more >Mocking with the Postman API
Step 1: Set up a collection for mocking · Step 2: Retrieve the collection ID · Step 3: Create a mock server with...
Read more >Stubbing and Mocking with Mockito and JUnit - Semaphore CI
Learn how to create true unit tests by mocking all external dependencies in your JUnit classes with the help of Mockito.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s exactly how TestNG works, and JUnit can be configured to work that way, but by default it does a new instance per test method. It’s a way to help ensure that the tests are independent of each other - barring anything external…
1.3.0 should be available on JCenter and Maven Central soon!