Thank you :o)

It's quite unexpected, but also not quite what i expected.
What you did here is run a Test::Class inside a Test::Spec.
What i would like would be to write a Test::Class in Test::Spec style, with the "describe/it" nested structure.

I still tried to add a "describe" assertion in the Test::Spec file, and a Test::More::ok() assertion into the Test.pm file, hoping that the TAP would produce a mixed output (i'm not sure how it would be useful, but i'm still interested by the experiment). But it didn't.
I added in the pm_class_spec_comb.pl file :

describe 'A mixed Test' => sub { it 'runs Test::Spec and Test::Class tests' => sub { [...] }; };
and in the Test.pm file :
use Test::More;
and
ok(1);
and it printed
ok 1 - test Hello
which is the normal Test::Class output. While i was hoping for it to write something mixed, like
"A mixed Test runs Test::Spec and Test::Class tests test Hello"

But anyway, this would still not be what i want.

Let me try to rephrase what i want.
In Test::Spec i can build "nested statements". For example,

describe 'A Fruit' => { [general tests on a Fruit, here] describe 'attached to its branch' => { [tests on Fruits which are still on their branch] [example :] it 'grows' => sub { ok(1); } }; describe 'fallen on the floor' => { [tests on Fruits which have fallen on the floor] }; describe 'on a pie' => sub { [tests on Fruits which are on a pie] }; };
And in each section, the output for each assertion will start with the corresponding context. For example i will read :
ok 1 - A fruit attached to its branch grows
This nested structure also enables nested declaration of the variables that i need for my tests. So, all the tests that are grouped together share the same variables, which can be re-initialized before each test, with the "before each" function. This way i don't need a $test variable to reinitialise and carry variables that are used in several tests : i can directly use my variables in several tests

See the @roll variable in my Game::Bowling example, for example. With Test::Class i would need to use $test->{roll} all the time, and i think i wouldn't be able to initialize it differently for different groups of tests.

I don't know if such a thing can be achieved with Test::Class.
I should maybe write my Game::Bowling example with Test::Class, to give a comparizon.


In reply to Re^2: Test::Class with Test::Spec's sugar ? by mascip
in thread Test::Class with Test::Spec's sugar ? by mascip

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.