Hi
Did anyone ever set up a CppUnit environment for blackbox
testing Orocos components?
I am currently thinking about in which way I woud best do
that. Suggestions and any experiences are welcome.
regards
Marc
The Orocos ProjectSmarter control in robotics & automation! |
|
Orocos - CppUnit Environment
Hi I am currently thinking about in which way I woud best do regards |
Orocos - CppUnit Environment
On Wednesday 18 March 2009 13:57:42 Bodmer Marc wrote:
> Hi
> Did anyone ever set up a CppUnit environment for blackbox
> testing Orocos components?
>
> I am currently thinking about in which way I woud best do
> that. Suggestions and any experiences are welcome.
CPPUNIT is a very basic testing environment. What you often need for testing
complexer objects like Orocos components are 'mock' objects. They represent
the part of the system your component interacts with. This is unfortunately
not yet common in many testing frameworks (in C++).
I've found cgreen which supports it, but which only has a C api:
http://www.lastcraft.com/cgreen.php
When you look at the current RTT unit tests, you can see that small mock
objects were created as well, but in an ad-hock way.
Anyway, the best way to black-box test an Orocos component is by using another
component, and running both components with SequentialActivity (which is the
default). You'll then be able to use the CPPUNIT_XYZ tests within your
component code because everything will be executed in the thread of the
caller, ie your unit test function.
Peter
Orocos - CppUnit Environment
On Mar 19, 2009, at 05:18 , Peter Soetens wrote:
> On Wednesday 18 March 2009 13:57:42 Bodmer Marc wrote:
>> Hi
>> Did anyone ever set up a CppUnit environment for blackbox
>> testing Orocos components?
>>
>> I am currently thinking about in which way I woud best do
>> that. Suggestions and any experiences are welcome.
>
> CPPUNIT is a very basic testing environment. What you often need for
> testing
> complexer objects like Orocos components are 'mock' objects. They
> represent
> the part of the system your component interacts with. This is
> unfortunately
> not yet common in many testing frameworks (in C++).
>
> I've found cgreen which supports it, but which only has a C api:
> http://www.lastcraft.com/cgreen.php
>
> When you look at the current RTT unit tests, you can see that small
> mock
> objects were created as well, but in an ad-hock way.
>
> Anyway, the best way to black-box test an Orocos component is by
> using another
> component, and running both components with SequentialActivity
> (which is the
> default). You'll then be able to use the CPPUNIT_XYZ tests within your
> component code because everything will be executed in the thread of
> the
> caller, ie your unit test function.
We do this extensively in automated unit tests, however we are using
SlaveActivity to do it. This allows us to single step component
updates, particularly useful where complex state machines are
involved. I'm not sure of the difference between Sequential and Slave
activities though?
S
Orocos - CppUnit Environment
Thanks for the useful feedback so far. Seems like I have to first read up
on Activities. Can you point me to a good example for such a component
test and mockobject in rtt/tests?
-----Ursprüngliche Nachricht-----
Von: S Roderick [mailto:kiwi [dot] net [..] ...]
Gesendet: Donnerstag, 19. März 2009 13:10
An: Peter Soetens
Cc: orocos-users [..] ...; Bodmer Marc
Betreff: Re: [Orocos-users] Orocos - CppUnit Environment
On Mar 19, 2009, at 05:18 , Peter Soetens wrote:
> On Wednesday 18 March 2009 13:57:42 Bodmer Marc wrote:
>> Hi
>> Did anyone ever set up a CppUnit environment for blackbox testing
>> Orocos components?
>>
>> I am currently thinking about in which way I woud best do that.
>> Suggestions and any experiences are welcome.
>
> CPPUNIT is a very basic testing environment. What you often need for
> testing complexer objects like Orocos components are 'mock' objects.
> They represent the part of the system your component interacts with.
> This is unfortunately not yet common in many testing frameworks (in
> C++).
>
> I've found cgreen which supports it, but which only has a C api:
> http://www.lastcraft.com/cgreen.php
>
> When you look at the current RTT unit tests, you can see that small
> mock objects were created as well, but in an ad-hock way.
>
> Anyway, the best way to black-box test an Orocos component is by using
> another component, and running both components with SequentialActivity
> (which is the default). You'll then be able to use the CPPUNIT_XYZ
> tests within your component code because everything will be executed
> in the thread of the caller, ie your unit test function.
We do this extensively in automated unit tests, however we are using SlaveActivity to do it. This allows us to single step component updates, particularly useful where complex state machines are involved. I'm not sure of the difference between Sequential and Slave activities though?
S
Orocos - CppUnit Environment
On Thursday 19 March 2009 13:10:01 S Roderick wrote:
> We do this extensively in automated unit tests, however we are using
> SlaveActivity to do it. This allows us to single step component
> updates, particularly useful where complex state machines are
> involved. I'm not sure of the difference between Sequential and Slave
> activities though?
Slave gives you full control of stepping (you need to call execute()),
Sequential will take the step immediately when an action is needed, for
example, if an event is queued, this will trigger the sequential activity to
process it. You can force a sequential activity step as well by calling
trigger() manually (i've just noticed a bug in the docs for
SequentialActivity, where it says that execute() is equivalent to trigger(),
it's not: execute() is a nop that always returns false).
So:
* Slave only notifies its master (if any) when trigger()ed and executes the
step on execute()
* Sequential ignores execute() and executes the step on trigger().
In a way, they are complementary.
Peter