Dhiraj Mahapatro
BDD facilitates writing correct code
Why BDD when we follow TDD?
TDD facilitates writing code correct
@TestFor(SampleController)
@Mock(Sample) class SampleControllerTests { void testControllerActionShowReturnsString() {
//Create mocked object instance new Sample(name: 'Sample')
//Call controller action
controller.show()
//Assert response assert controller.response.contentAsString == 'Hello World' } }
But we never tested:
RESULT >>
@TestFor(SampleController)
@Mock(Sample) class SampleControllerTests extends ControllerSpec{ void "test controller should return Grails and Ale"() {
given: "A sample object with name Sample"
new Sample(name: 'Sample')
when: "Controller show action is called"
controller.show()
then: "The response should be Grails and Ale"
controller.response.contentAsString == 'Grails and Ale' } }
twitter # @pniedrw