mercredi 7 janvier 2015

Verifying that a save was called in a Service Test

I'm using Grails 2.4 and I have a helper service that creates a specific domain class, sets up the dependencies surrounding it and then finally saves the object to the database, within a promise.


How would I test this service?


An example of the service is:



def persist(name, objectId, depTwoId) {
Person p = Person.findByName(name)
Object o = Object.findById(objectId)

RepObject rob = RepObject(p, o) //Ok you get the idea here

def task = Promises.task {
rob.save()
}
}


I don't care, within the context of the unit test, if there was a save to the database. I just want to know that it was called.


Aucun commentaire:

Enregistrer un commentaire