Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test Showing Why "as" operator is important
package com
import grails.test.GrailsUnitTestCase;
import com.SomeService
class SomethingTests extends GrailsUnitTestCase {
void testSomething() {
Something thing = new Something()
// thing.someService = [ get : { a -> throw new Throwable() } ] as SomeService // works
thing.someService = [ get : { a -> throw new Throwable() } ] // need the "as" operator!
assert thing.methodWeAreTesting()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment