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 :
and in the Test.pm file :describe 'A mixed Test' => sub { it 'runs Test::Spec and Test::Class tests' => sub { [...] }; };
anduse Test::More;
and it printedok(1);
which is the normal Test::Class output. While i was hoping for it to write something mixed, likeok 1 - 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,
And in each section, the output for each assertion will start with the corresponding context. For example i will read :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] }; };
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 testsok 1 - A fruit attached to its branch grows
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |