unit test: apply same test case to different fixtures

View: New views
7 Messages — Rating Filter:   Alert me  

unit test: apply same test case to different fixtures

by hm567 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have auto test cases that can take fixtures whose members they access in a
uniform way.

Say   struct F1... Fn

BOOST_FIXTURE_TEST_CASE( test_case1 , F1 ... Fn )
{
  //same code for all Fi
}

Is there a way to do this?

Regards,

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: unit test: apply same test case to different fixtures

by Gennadiy Rozental-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hicham Mouline <hicham <at> mouline.org> writes:

>
> I have auto test cases that can take fixtures whose members they access in a
> uniform way.
>
> Say   struct F1... Fn
>
> BOOST_FIXTURE_TEST_CASE( test_case1 , F1 ... Fn )
> {
>   //same code for all Fi
> }
>
> Is there a way to do this?
>
> Regards,
>

1. Make Fi inherit from Fi+1.
2. Use something like this:

template<typename T1,typename T2>
struct FixtureCollector : T1, T2 {};

You can now either implement above using variardic templates or implement macro
that will convert PP sequence into sequence of FixtureCollector<T1,...>:

For example

FIXTURES((T1)(T2)(T3)) should generate:

FixtureCollector<T1,FixtureCollector<T2,T3> >

use it :

BOOST_FIXTURE_TEST_CASE( test_case1 , FIXTURES((T1)(T2)(T3)) )
{
}

Gennadiy




_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: unit test: apply same test case to different fixtures

by hm567 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> -----Original Message-----
> From: boost-users-bounces@... [mailto:boost-users-
> bounces@...] On Behalf Of Gennadiy Rozental
> Sent: 07 July 2009 14:46
> To: boost-users@...
> Subject: Re: [Boost-users] unit test: apply same test case to different
> fixtures
>
> Hicham Mouline <hicham <at> mouline.org> writes:
>
> >
> > I have auto test cases that can take fixtures whose members they
> access in a
> > uniform way.
> >
> > Say   struct F1... Fn
> >
> > BOOST_FIXTURE_TEST_CASE( test_case1 , F1 ... Fn )
> > {
> >   //same code for all Fi
> > }
> >
> > Is there a way to do this?
> >
> > Regards,
> >
>
> 1. Make Fi inherit from Fi+1.
> 2. Use something like this:
>
> template<typename T1,typename T2>
> struct FixtureCollector : T1, T2 {};
>
> You can now either implement above using variardic templates or
> implement macro
> that will convert PP sequence into sequence of
> FixtureCollector<T1,...>:
>
> For example
>
> FIXTURES((T1)(T2)(T3)) should generate:
>
> FixtureCollector<T1,FixtureCollector<T2,T3> >
>
> use it :
>
> BOOST_FIXTURE_TEST_CASE( test_case1 , FIXTURES((T1)(T2)(T3)) )
> {
> }
>
> Gennadiy
>
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users@...
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: unit test: apply same test case to different fixtures

by hm567 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> -----Original Message-----
> From: boost-users-bounces@... [mailto:boost-users-
> bounces@...] On Behalf Of Gennadiy Rozental
> Sent: 07 July 2009 14:46
> To: boost-users@...
> Subject: Re: [Boost-users] unit test: apply same test case to different
> fixtures
>
> Hicham Mouline <hicham <at> mouline.org> writes:
>
> >
> > I have auto test cases that can take fixtures whose members they
> access in a
> > uniform way.
> >
> > Say   struct F1... Fn
> >
> > BOOST_FIXTURE_TEST_CASE( test_case1 , F1 ... Fn )
> > {
> >   //same code for all Fi
> > }
> >
> > Is there a way to do this?
> >
> > Regards,
> >
>
> 1. Make Fi inherit from Fi+1.
> 2. Use something like this:
>
> template<typename T1,typename T2>
> struct FixtureCollector : T1, T2 {};
>
> You can now either implement above using variardic templates or
> implement macro
> that will convert PP sequence into sequence of
> FixtureCollector<T1,...>:
>
> For example
>
> FIXTURES((T1)(T2)(T3)) should generate:
>
> FixtureCollector<T1,FixtureCollector<T2,T3> >
>
> use it :
>
> BOOST_FIXTURE_TEST_CASE( test_case1 , FIXTURES((T1)(T2)(T3)) )
> {
> }
>
> Gennadiy

Hi
Pressed Send too early.

The question is how to run the test case on T1 then on T2 then .... on Tn ,
on each one separately

Rds,

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: unit test: apply same test case to different fixtures

by Steven Watanabe-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

AMDG

Hicham Mouline wrote:

>> Hicham Mouline <hicham <at> mouline.org> writes:
>>
>>    
>>> I have auto test cases that can take fixtures whose members they
>>>      
>> access in a
>>    
>>> uniform way.
>>>
>>> Say   struct F1... Fn
>>>
>>> BOOST_FIXTURE_TEST_CASE( test_case1 , F1 ... Fn )
>>> {
>>>   //same code for all Fi
>>> }
>>>
>>> Is there a way to do this?
>>>
>>> Regards,
>>>
>>>      
>> 1. Make Fi inherit from Fi+1.
>> 2. Use something like this:
>>
>> template<typename T1,typename T2>
>> struct FixtureCollector : T1, T2 {};
>>
>> You can now either implement above using variardic templates or
>> implement macro
>> that will convert PP sequence into sequence of
>> FixtureCollector<T1,...>:
>>
>> For example
>>
>> FIXTURES((T1)(T2)(T3)) should generate:
>>
>> FixtureCollector<T1,FixtureCollector<T2,T3> >
>>
>> use it :
>>
>> BOOST_FIXTURE_TEST_CASE( test_case1 , FIXTURES((T1)(T2)(T3)) )
>> {
>> }
>>    
>
> The question is how to run the test case on T1 then on T2 then .... on Tn ,
> on each one separately
>  

In other words, you'd like there to be a
BOOST_FIXTURE_TEST_CASE_TEMPLATE
to complement
BOOST_AUTO_TEST_CASE_TEMPLATE

In Christ,
Steven Watanabe

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: unit test: apply same test case to different fixtures

by Gennadiy Rozental-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Steven Watanabe <watanabesj <at> gmail.com> writes:

> >> BOOST_FIXTURE_TEST_CASE( test_case1 , FIXTURES((T1)(T2)(T3)) )
> >> {
> >> }
> >>    
> >
> > The question is how to run the test case on T1 then on T2 then .... on Tn ,
> > on each one separately

I must say you left me a bit puzzled. What does it you are trying to do? Run the
same code against different fixtures? Kinda weird, don't you think?

>
> In other words, you'd like there to be a
> BOOST_FIXTURE_TEST_CASE_TEMPLATE
> to complement
> BOOST_AUTO_TEST_CASE_TEMPLATE

Not really, as far as I can tell.

Gennadiy

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: unit test: apply same test case to different fixtures

by hm567 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> -----Original Message-----
> From: boost-users-bounces@... [mailto:boost-users-
> bounces@...] On Behalf Of Gennadiy Rozental
> Sent: 08 July 2009 16:17
> To: boost-users@...
> Subject: Re: [Boost-users] unit test: apply same test case to different
> fixtures
>
> Steven Watanabe <watanabesj <at> gmail.com> writes:
>
> > >> BOOST_FIXTURE_TEST_CASE( test_case1 , FIXTURES((T1)(T2)(T3)) )
> > >> {
> > >> }
> > >>
> > >
> > > The question is how to run the test case on T1 then on T2 then ....
> on Tn ,
> > > on each one separately
>
> I must say you left me a bit puzzled. What does it you are trying to
> do? Run the
> same code against different fixtures? Kinda weird, don't you think?
>
> >
> > In other words, you'd like there to be a
> > BOOST_FIXTURE_TEST_CASE_TEMPLATE
> > to complement
> > BOOST_AUTO_TEST_CASE_TEMPLATE
>
> Not really, as far as I can tell.
>
> Gennady

The different fixtures have the same member names, even if their types are
different
and the test case code uses those member with the same syntax... It's bit
like if the
fixture was a template argument...

regards,

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users