lundi 24 juin 2019

Play framweok WSClient testing

I have a service class in my code, for example, UserService. It has a WSClient member which makes calls to a web service. I would like to write test cases for the UserService methods.

I did some research on testing WSClient but did not find any use case like mine. Should I establish a live test service, or do mocking? This is another question.

class UserService @Inject()(ws: WSClient) {


def getUser(userId: UUID) = {// some code}

def createUser(obj: User) = {// another piece of code}

These methods use the WSClient to call the web service endpoints.

I would like to write test cases for these methods. Which is the best, setting up a test service and call that or mocking the WSClient?

Aucun commentaire:

Enregistrer un commentaire