mercredi 27 juillet 2016

Grails specification test with service

I am trying to use service in Spock specification test.

 def "Registrate company and user with some valid data"() {
        given:
            RegistrationService registrationService = Mock()
            controller.registrationService = registrationService
        when:"Something"
            def data =  registrationService.register('test@test.sk','a','a','a','12345576','159159159','a','a','a','a','a')
        then:"Everyhing is fine"
            assert data.instance1.hasErrors == false
            assert data.instance2.hasErrors == false
            assert data.instance3.hasErrors == false
}

I am getting Null pointer exception java.lang.NullPointerException: Cannot get property 'instace1' on null object.

If I run the service through my controller, then everything works fine.

Sevice returns this [instance1:instance1,instance2:instance2,instance3:instance3]

Aucun commentaire:

Enregistrer un commentaire