Questions tagged [turtle-mock]

C++ mock object library for Boost

Turtle is a C++ mock object library based on Boost.

Features:

  • simple and compact syntax
  • easy customization of constraints
  • informative and customizable logs
  • optional but full integration with Boost.Test
  • automatic verification of mock objects upon destruction
  • ANSI/ISO C++03 compatible

Home page: http://turtle.sourceforge.net/

15 questions
6
votes
2 answers

Create Mock for a constant method in Turtle

I have, class CFoo : public CFooPar { public: CFoo(){} ~CFoo(){} virtual bool ret() const { return true; } }; How can I create mock class for this virtual bool ret() const method? Thank you!
domlao
  • 15,663
  • 34
  • 95
  • 134
2
votes
1 answer

How to Mock calls to boost.asio library?

I need to develop a c++ class that will act as a client for a TCP Server, lets call it myManager, this class will espose a few methods: connect() disconnect() send_command(std::string msg) getStatus() ecc. All this methods will perform some…
Gionata Benelli
  • 357
  • 1
  • 3
  • 20
2
votes
1 answer

How to set up c++ turtle mock library with boost::test?

I'm trying to set up the turtle-mock library with the boost::test framework. I don't know how to do it, nothing is said about that neither in the documentation... I tried to simply copy the library source into boost/include. I also tried to copy the…
lecoqlibre
  • 140
  • 2
  • 13
2
votes
2 answers

How to mock method with pointer argument

Is it possible to mock method that retrieves pointer (or reference) as argument and change pointed object? I use turtle library - http://turtle.sourceforge.net/ -> A C++ mock object library for Boost. (I know it is not popular library but it can be…
peter55555
  • 1,413
  • 1
  • 19
  • 36
2
votes
2 answers

Why to use MOCK_NON_CONST_METHOD_EXT for operator float() in Boost Turtle?

I am using Boost 1.46 with Turtle lib 1.2.4 and compiler from Visual Studio Express 2013. I have following class to MOCK: struct IPredicate { virtual ~IPredicate() {} virtual bool operator()(float value) = 0; }; When I mock operator() with…
2
votes
1 answer

Turtle (mock framework) compilation errors

I'm trying to compile a simple example in Turtle (with boost unit test framework) and am getting compilation errors from within Turtle. I'm assuming that Turtle doesn't really have errors and it's something that I'm doing wrong or have…
Eran
  • 2,324
  • 3
  • 22
  • 27
2
votes
1 answer

Call both returns and calls action in a single MOCK_EXPECT

Can I call both returns and calls action at the same time in a single MOCK_EXPECT call? Like, MOCK_EXPECT(a.method).calls(functor).returns(value); Thanks
domlao
  • 15,663
  • 34
  • 95
  • 134
1
vote
2 answers

Turtle Mock: MOCK_EXPECT fails if mocked class method returns a value

I am a long time lurker in the board, and is needless to say that you guys are the best and I am grateful for all the times you saved my job. That is my first time post here and I hope I don't mess it up. I am writing a C++ Boost application for…
0
votes
0 answers

How to mock function calls in mock-turtle?

I have a piece of code implementing a class that I want to test, lets call it A.cpp and the test test_A.cpp. The A.cpp file uses some functions from a library that commands a particular device, lets call this libdevice. In particular, the A class…
Gionata Benelli
  • 357
  • 1
  • 3
  • 20
0
votes
0 answers

how to mock calls to boost::posix_time::microsec_time::local_time()?

I'm having some issue trying to test some fuctionalities of a cpp class. I'm testing my class, let's call it myManager, which has a public method called generateActionCommand that uses boost posix_time function local_time() to return a ptime…
Gionata Benelli
  • 357
  • 1
  • 3
  • 20
0
votes
1 answer

Turtle Mock: How to ignore unexpected calls?

Is it possible to ignore unexpected method calls for Turtle Mock? During my test the mocked method is called multiple times. I want to check only one invocation with specific parameters per test. Now I have to write one enormous test where I have to…
w00drow
  • 468
  • 2
  • 11
0
votes
2 answers

Mocking elements of an array in turtle mock

I need to mock elements of an array in turtle mock. Unfortunately, because the turtle mock macro MOCK_BASE_CLASS adds extra "gunk", e.g. mock::object, mock::detail::base<> etc, the sizes of the base and mock types are no longer identical. Therefore,…
Olumide
  • 5,397
  • 10
  • 55
  • 104
0
votes
1 answer

Mock object with turtle mock for boost::test

I'm trying to create a unittest with mocked objects using turtle and boost. But the example doesn't work and I can't find the error. I expect no errors but the result is: $ ./unittest Running 1 test case... Start Display:…
Thomas Sablik
  • 16,127
  • 7
  • 34
  • 62
0
votes
0 answers

BoostTest: Can't access to protected members

I'm using the BoostTest Framework (version 1.57.0) with Turtle as mock libary (version 1.3.0). I'm able to access public and private functions in a test case, but I can't access protected functions. I'm able to mock these protected functions with…
Dave
  • 97
  • 2
  • 6
0
votes
3 answers

How to make expectations on a mock object created inside the tested object?

I want to unit test a class that looks like this: template class MyClass { ... void someMethod() { T object; object.doSomething(); } ... }; I want to unit test this class, so I create a mock class for T: struct…
petersohn
  • 11,292
  • 13
  • 61
  • 98