I'm a newbie to Java Unit test. The issue I'm facing is that I need to develop a JUnit test to send requests to a server'API to test two methods: addUser
and deleteUser
. If I want to add/delete a user from the server, I need to get an authentication token from the server; However, due to some issue on the server side, I currently can't get a valid token. So what comes to my mind, is to mock the server's behavior that if the server receives requests from the Unit test, it could response with a JSON data which indicates the status of the add/delete-user operations.
Because I'm totally new to JUnit. I have no clue how to implement the operation. So my question is what is probably the easiest way to apply the mock?