mercredi 9 décembre 2015

Grails / Spock testing provide stubbed implementation for a service

Currently i have a Grails Service that actually publishes messages to an AMQP provider. I would like to stub the message publishing by replacing the publish method so that it does not publish to AMQP but stores the messages in a list

Example:

class AService {
    EventPublisherService eventPubliserService
    def createSomething() {
        eventPublisherService.publishEvent(..)
    }
}

Is there a way to stub the 'createSomethingMethod' in a integration test so i can check the published events later on in a list?

Aucun commentaire:

Enregistrer un commentaire