mardi 4 novembre 2014

Grails Unit Test Failing


Vote count:

0




So, I am starting learning groovy & grails. I am trying to write unit tests for my controller like this:



void testSave() {

params.productName = 'ProdName'
params.productBarCode = '123'
params.productStore = 'ProdStore'
def response = controller.save()
assert response.productInstance.productName == 'ProdName'

}


and this is the controller action



def save() {
def productInstance = new Product(params)
if (!productInstance.save(flush: true)) {
render(view: "create", model: [productInstance: productInstance])
return
}

flash.message = message(code: 'default.created.message', args: [message(code: 'product.label', default: 'Product'), productInstance.id])
redirect(action: "show", id: productInstance.id)
}


and this is the exception it throws when 'test-app'



groovy.lang.MissingMethodException: No signature of method: xxx.Product.save() is applicable for argument types: () values: []
Possible solutions: save(), save(boolean), save(java.util.Map), wait(), any(), wait(long)
at xxx.ProductController.save(ProductController.groovy:59)
at xxx.ProductControllerTests.testSave(ProductControllerTests.groovy:35)


I am sorry if this question is too naive. Please help Thanks



asked 1 min ago

Mr.777

369






Grails Unit Test Failing

Aucun commentaire:

Enregistrer un commentaire