Questions tagged [gmock]

Gmock is a mocking framework for Groovy. For questions relating to Google Mock, use tag [googlemock] instead.

Gmock (Groovy mocking framework) for the Groovy programming language "is all about simple syntax and readability of your tests so you spend less time learning the framework and more writing code."

12 questions
3
votes
1 answer

Mock testing in Grails 2.0 errors

I've recently upgraded a Grails 1.3.7 project up to Grails 2.0.4 and noticed that many of my unit tests with mocking have started to fail. The Controller tests seem to pass just fine, the issue comes when you have Services collaborating with one…
Jeremy Anderson
  • 158
  • 2
  • 7
2
votes
0 answers

Error : The dependency target "gmock" of target "yarpl-tests" does not exist while building yarpl - Ubuntu 16.04

I am trying to build YARPL library that I got using rsocket library in github. I followed instructions as mentioned in the readme. # inside root ./yarpl mkdir -p build cd build cmake ../ -DCMAKE_BUILD_TYPE=DEBUG make -j ./yarpl-tests But in the…
Manasvini Ganesh
  • 483
  • 5
  • 16
2
votes
1 answer

Partial mock using groovy gmock v 0.8

I am not able to figure out partial mocking in groovy using gmock. I have the following code: class Foo { Integer val Foo() { this.val = 4; } Integer printHello() { return getValue() } Integer getValue() { …
thePoly_glot
  • 135
  • 1
  • 2
  • 11
2
votes
1 answer

Testing a Grails controller using a mock service with GMock (0.8.0)

I have a grails 2.1 app which has a controller that calls a method on a service, passing in a request and a response: class FooController { def myService def anAction() { response.setContentType('text/xml') …
DJOodle
  • 323
  • 2
  • 16
1
vote
2 answers

Partial Mocking Class with Multiple Static Methods with GMock

I'm using GMock to add some unit testing to our existing Java projects. We have multiple places where the methods needing to be tested are static methods, which utilize additional static methods within the method we want to test. I would like to be…
Patrick
  • 13
  • 3
1
vote
1 answer

Mocking Util class's static method using gmock

class SomeService{ public String getValue(){ return SomeUtil.generateValue(); } } class SomeUtil{ public static String generateValue() { return "yahoo"; } } I want to unit test the SomeService.getValue method. I am trying the…
Ankit Gupta
  • 275
  • 3
  • 12
1
vote
1 answer

How to mock a method that contains a closure using gMock for groovy?

I am using gMock for groovy to create unit tests. I have a base class which contains an ArrayList of "Players" I have another class that works as my GUI interface. A method in that user interface will take the list of Players and display the…
TroyB
  • 195
  • 1
  • 14
0
votes
2 answers

Using GMock with Spring how to I setup up a spring context only once for several tests?

I find that when running multiple gmock tests using and in memory database I get errors about table already being there. It seems to run the spring context creation multiple times, even though it's only set once in a given test class as a field to…
barrymac
  • 2,750
  • 1
  • 20
  • 32
0
votes
3 answers

Can gmock mock static methods of Java classes? Alternative?

I could not get it to work. It's like the method is not mocked. Are there alternative groovy testing frameworks that work better to mock static Java methods? Update 02/Mar/2011: Adding code: I am actually trying to mock the Scala XML.loadXml (I am…
mbdev
  • 6,343
  • 14
  • 46
  • 63
0
votes
1 answer

How to Unit Test (mock class) in Groovy with nested closures?

I modified the code from here to look very much like the code I have and am trying to create Unit Tests for. While I would like to ask "what is the best way" to test this, I will be quite satisfied with any way to create a decent Unit Test! I…
JoeG
  • 7,191
  • 10
  • 60
  • 105
0
votes
1 answer

Grails GMock error when mocking OutputStream

I have had a hell of a time trying to get a mocking framework up and running that can test my SFTP Service. I was familiar with EasyMock, PowerMock and JMockit but ended up going with GMock. test ('org.gmock:gmock:0.8.2') { excludes 'junit' } Now…
Jon Tinsman
  • 566
  • 4
  • 21
0
votes
1 answer

Grails 2.2.2: Testing interceptors in ControllerTests with GMock

When our codebase was still in Grails 2.1.4, this unit test for our interceptors worked with full coverage: @Before void setUp() { gmc = new GMockController() apiProducts = gmc.mock() api.products.returns(apiProducts).stub() …
Ace Subido
  • 86
  • 9