Grails Unit Test Failing -


So I'm starting to learn Grivi; Grails I am trying to write unit tests for my controller like this:

  zero testSave () {params.productName = 'ProdName' params.productBarCode = '123' params.productStore = 'ProdStore def' response = controller. Save () response presentation. Product Instances Product Name == 'ProdName'}  

And this is the controller action

  def save () {DEF Product instance = new product (Paramos) if (! Product Instance.Save (Flush: True)) {Render (See: "Create", Model: [Product Instance: Product Instance]) Returns} Flash. Message: (message: 'product.label', default: 'product'), productInstance.id (message: code: 'default (number: "show", id: productInstance.id)} [edit]. ]  

And when it is an exception, throws 'test-aap'

  groovy.lang.MissingMethodException: any signature of the method: xxx.Product.save () Not applicable for logic types: () valu Es: [] Possible solutions: save (), save (boolean), save (java.util.Map), wait (), any (), wait ( Long) xxx Product Controller (Manufacturer Controller.Groovy: 59) On Xxx.ProductControllerTests.testSave (ProductControllerTests.groovy: 35)  

If this question is too naive then I'm sorry, please thank you

< / Div>

Until the domain instance is joked in the test class, it will not be enabled

Use @Mock (product) at the class level at class level.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -