Aquileo | Recent changes to Project Turtlehttps://sourceforge.net/p/turtle/2024-10-02T15:16:03.844000ZRecent changes to Project TurtleAquileo | #79 method called several times abd check once with specific parameters2024-10-02T15:16:03.844000Z2024-10-02T15:16:03.844000ZMathieu Champlonhttps://sourceforge.net/u/mat007/https://sourceforge.net64409c244925d3fad27bac1841524bfb6fa78eec<div class="markdown_content"><ul>
<li><strong>status</strong>: open --> closed</li>
</ul></div>Aquileo | #79 method called several times abd check once with specific parameters2024-10-02T15:15:50.083000Z2024-10-02T15:15:50.083000ZMathieu Champlonhttps://sourceforge.net/u/mat007/https://sourceforge.net6b2f54eb57daa950e2b587826062a55cc3bd11cf<div class="markdown_content"><p>Hey! Sorry for missing your ticket. The project has migrated to <a href="https://github.com/mat007/turtle." rel="nofollow">https://github.com/mat007/turtle.</a></p></div>Aquileo | method called several times abd check once with specific parameters2023-05-04T11:34:41.710000Z2023-05-04T11:34:41.710000Zgambrhttps://sourceforge.net/u/gambr/https://sourceforge.net20d27e53e8e3d33768911ac3f4d36e1fc89bc53c<div class="markdown_content"><p>Dear Mathieu,<br/>
in my test a setValue(string name, double value) method is called several times and I would like to verify it is called exactly once with specific parameters.</p>
<div class="codehilite"><pre><span></span><code><span class="n">MOCK_EXPECT</span><span class="p">(</span><span class="n">serviceMock</span><span class="o">-></span><span class="n">setValue</span><span class="p">)</span><span class="o">.</span><span class="n">exactly</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">with</span><span class="p">([](</span><span class="k">const</span><span class="w"> </span><span class="n">std</span><span class="p">::</span><span class="n">string</span><span class="o">&</span><span class="w"> </span><span class="n">name</span><span class="p">,</span><span class="w"> </span><span class="n">double</span><span class="w"> </span><span class="n">value</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">name</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">"INPUT_HW_CUEING_AOR_AUTO"</span><span class="p">)</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="n">std</span><span class="p">::</span><span class="n">string</span><span class="p">::</span><span class="n">npos</span><span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="n">value</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mf">1.0</span><span class="p">;</span>
<span class="p">});</span>
</code></pre></div>
<p>Since setValue() is called also other times with different arguments, the test fails.<br/>
I tried in vain with:</p>
<p>MOCK_EXPECT(serviceMock->setValue).at_least(1).with(mock::any, mock::any);</p>
<p>before or after the other MOCK_EXPECT line but it doesn't work.</p>
<p>Is it possible to handle this case? If so, how?</p>
<p>Regards<br/>
Gianni</p></div>Aquileo | method called several times abd check once with specific parameters2023-05-04T11:34:41.710000Z2023-05-04T11:34:41.710000Zgambrhttps://sourceforge.net/u/gambr/https://sourceforge.net3e76712184da8d9d1ddda48ae4ad092b9e317207<div class="markdown_content"><p>Ticket 79 has been modified: method called several times abd check once with specific parameters<br/>
Edited By: Mathieu Champlon (mat007)<br/>
Status updated: 'open' => 'closed'</p></div>Aquileo | #78 MOCK_BASE_CLASS2021-11-26T02:37:40.490000Z2021-11-26T02:37:40.490000ZMing Chenghttps://sourceforge.net/u/chengm349/https://sourceforge.net70b4a5c66b4debc50874e0f293a260100b27bf1b<div class="markdown_content"><p>I need MyApplication to be constructed completely although I use Mock_MyApplication as a child class. </p></div>Aquileo | MOCK_BASE_CLASS2021-11-26T02:32:24.125000Z2021-11-26T02:32:24.125000ZMing Chenghttps://sourceforge.net/u/chengm349/https://sourceforge.net9afca45f2cf1d642311835fd8c147dce87bd01a3<div class="markdown_content"><p>MOCK_BASE_CLASS( Mock_MyApplication, MyApplication ) <br/>
{<br/>
MOCK_METHOD( stop, 0)<br/>
};</p>
<p>MyApplication constructor takes a parameter of MyConfiguration.</p>
<p>compiler complains about this line:</p>
<p>struct Test<br/>
{<br/>
Test(const MyConfiguration& cfg) : m_application(cfg) {}<br/>
......<br/>
Mock_MyApplication m_application;<br/>
}</p></div>Aquileo | #77 How to mock some functions in my class2021-11-19T04:27:00.338000Z2021-11-19T04:27:00.338000ZMing Chenghttps://sourceforge.net/u/chengm349/https://sourceforge.net00ff6a4230b89fed77c1d08bac3320da0d104012<div class="markdown_content"><p>Please kindly let me know if my question/sample is not very clear. I am keen to use the tool in my important and urgent project right now.</p></div>Aquileo | How to mock some functions in my class2021-11-18T07:43:30.934000Z2021-11-18T07:43:30.934000ZMing Chenghttps://sourceforge.net/u/chengm349/https://sourceforge.netc6d87620b133ff94922e00f326c278986bd7c605<div class="markdown_content"><p>Hi Mathieu Champlon and Team,</p>
<p>I am studying <a href="http://turtle.sourceforge.net/index.html" rel="nofollow">http://turtle.sourceforge.net/index.html</a> now and try to use the tool.</p>
<p>class MyClass<br/>
{<br/>
friend class TestMyClass;<br/>
public:<br/>
bool send(void* p); // this is a TCP/IP call. So I'd like to mock it to always return me TRUE<br/>
private:<br/>
...<br/>
... // quite some member data<br/>
}</p>
<p>Looks like I may try something like this, but not sure how to move correctly:</p>
<p>MOCK_CLASS( mock_MyClass )<br/>
{<br/>
MOCK_METHOD( send, nullptr);<br/>
};</p>
<p>BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_mock_class )<br/>
{<br/>
mock_MyClass c;<br/>
BOOST_REQUIRE(c.send(nullptr));<br/>
}</p>
<ol>
<li>How to use MOCK_CLASS to test MyClass?</li>
<li>Is there anyway I can still make use of TestMyClass together with mock_MyClass ?</li>
</ol></div>Aquileo | #76 MOCK_METHOD calling base class methods instead of mocked method.2021-08-09T17:12:52.471000Z2021-08-09T17:12:52.471000Zhttps://sourceforge.nethttps://sourceforge.net2cffa8364af9374efe003022a002f732b6b839e7<div class="markdown_content"><p>Can't seem to figure out why the mock method is just calling the base class method. Some help would be much appreciated.</p></div>Aquileo | MOCK_METHOD calling base class methods instead of mocked method.2021-08-09T17:11:25.036000Z2021-08-09T17:11:25.036000Zhttps://sourceforge.nethttps://sourceforge.netbd47b150eb369043bbf4412c93f8e375d5aaeec6<div class="markdown_content"><p>MOCK_METHOD calls seem to be ignored. mock::verify confirms that the mock_method was never called.</p>
<p>Base class method is called. </p>
<p>Attaching source files, files included are mimicking the functionality of actual files. As well as a console output file. </p></div>