lundi 22 décembre 2014

Grails unit test mock service vs assign service instance

What is the difference between mocking service and assign instance of class to service?


For example:



class MyService {

def CallServiceMethod(){
my business logic
}
}

class MyController {
def myService

def callServiceMethod(){
myService.callServiceMethod()
}
}


@TestFor(MyController)
class MyControllerTests {

@Before
void setup() {
controller?.myService = new MyService()
vs
controller?.myService = mockFor(MyService)
}

void testCallServiceMethod(){
controller.callServiceMethod()
}
}


Any one help me please?


Aucun commentaire:

Enregistrer un commentaire