unit testing - mockRequest doesn't work in grails 2.x -


i have code get's file request object

        if (!request.getfile('uploadfile').isempty()) {         ...     } 

to test used mockrequest. have written unit test case in grails 1.3.7 worked fine same fails after upgrading grails 2.2.4

        mockrequest.metaclass.getfile = { file ->         return new mockmultipartfile('uploadfile', new byte[0])     } 

  • match signature while using metaclass. use string file ->.

  • hope this answer can in ways.

fyi. mockrequest no more used grails 2.x. can use request instead.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -