[Training Video - 4] [Groovy] Initializing log inside class with constructor
TestService s = new TestService(log,context,testRunner)
s.xyz()
class TestService{
def log
def context
def testRunner
public TestService(log,context,testRunner){
this.log=log
this.context=context
this.testRunner=testRunner
}
public void xyz(){
log.info "hello"
}
}
Run result:
Tue Oct 06 20:54:29 CST 2015:INFO:hello
浙公网安备 33010602011771号