Igloo with Google Mocks

112 views
Skip to first unread message

Symon Rottem

unread,
Nov 27, 2013, 9:21:35 AM11/27/13
to igloo-...@googlegroups.com
I've been trying to get Igloo up and running with Google Mocks but I'm not having a lot of luck.  As soon as I include a mock in a test (even without exercising it) my test app barfs up a runtime error.  Does anyone have any tips?

Cheers,

Symon.

Joakim Karlsson

unread,
Nov 27, 2013, 9:46:34 AM11/27/13
to igloo-...@googlegroups.com
I haven't tried it myself, but have you taken a look at this:


/Joakim


--
You received this message because you are subscribed to the Google Groups "Igloo-testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to igloo-testin...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Symon Rottem

unread,
Nov 27, 2013, 9:50:32 AM11/27/13
to igloo-...@googlegroups.com

I have, but I'm not having any luck and after a day of fiddling around I'd be pulling my hair out if I had any. :-)

I can't figure out what to do with the test listener - I'm a bit of a c++ newb and I can't figure out how to use it with Igloo.

Symon.

Symon Rottem

unread,
Nov 27, 2013, 12:38:08 PM11/27/13
to igloo-...@googlegroups.com

from what I can tell from a test listener used for boost the general idea is that if result in the listener equates to failed then the information about the error (e.g. filename, line number, error summary) should be pushed to the testing framework.

Http://paste in.com/QDh3ck8g

I'm not clear on how I can do that - does igloo support having errors pushed to it somehow?

Cheers,

Symon.

Joakim Karlsson

unread,
Nov 27, 2013, 1:38:19 PM11/27/13
to igloo-...@googlegroups.com
I created a quick test project for this at https://github.com/joakimkarlsson/igloo_gmock_test.git

This works on my setup. It doesn't use any gmock specific test listener. It just tells gmock to throw exceptions and these will get caught by Igloo.

/Joakim


--

Symon Rottem

unread,
Nov 27, 2013, 4:15:41 PM11/27/13
to igloo-...@googlegroups.com
Thanks Joakim!

Your sample runs fine here too and now I think I see the source of problem I'm experiencing; in my test I was setting up the mock outside the specification in the context so that it could be used by multiple specifications - e.g.:

struct foo
{
  virtual void call_me() = 0;
};

struct mock_foo : public foo
{
  MOCK_METHOD0(call_me, void());
};

Describe(Spec_with_mocks)
{
  It(Fails)
  {
    EXPECT_CALL(foo, call_me());

  }



mock_foo foo; //BOOM!
};

This seems to be the way the site documentation dictates tests can be structured but it doesn't seem to work with Google Mocks. Have I got it wrong?

Cheers,

Symon.

Joakim Karlsson

unread,
Nov 28, 2013, 6:35:13 AM11/28/13
to igloo-...@googlegroups.com
I've looked a bit more into it, and what happens is that when Igloo is registering its contexts it creates an instance of each context in order to trigger registration of any nested contexts.

This happens before main is executed and gmock cannot handle that. For now, you'll have to create the mock in each test method. But I'm looking at going the test listener route.

gmock seems to be verifying mocks in the destructor of each mock, so throwing exceptions there is probably not a viable solution in the long run.

/Joakim

Symon Rottem

unread,
Nov 28, 2013, 8:53:33 AM11/28/13
to igloo-...@googlegroups.com
Thanks very much for your help Joakim - I appreciate it.
Reply all
Reply to author
Forward
0 new messages