Skip to content

Instantly share code, notes, and snippets.

@grimrose
Created February 3, 2013 15:33
Show Gist options
  • Save grimrose/4702190 to your computer and use it in GitHub Desktop.
Save grimrose/4702190 to your computer and use it in GitHub Desktop.
MethodExtractExampleTestをGroovyで書き直すとエラーになる件について
package chapter11
import org.junit.Test
import static org.hamcrest.CoreMatchers.is
import static org.junit.Assert.assertThat
class MethodExtractExampleGroovyTest {
@Test
void "doSomethingでdateに現在時刻が設定される"() {
// Setup
final Date current = new Date()
MethodExtractExample.metaClass {
newDate = {
println("call expanded.")
current
}
}
MethodExtractExample sut = new MethodExtractExample()
// Exercise
sut.doSomething();
// Verify
assertThat(sut.date, is(current))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment