in reply to Test::Class with Test::Spec's sugar ?
I haven't used either Test::Spec or Test::Class previously. I managed to get these interacting at a very basic level: calling Test::Class::->runtests; from within a Test::Spec it() function.
The main script:
ken@ganymede: ~/tmp $ cat pm_class_spec_comb.pl #!/usr/bin/env perl use strict; use warnings; use Test::Spec; use Test::Class::Example::Hello::Tests; it 'runs Test::Spec and Test::Class tests' => sub { diag('Hello, world! (from Test::More::diag() as: diag())'); print qq{Hello, world! (from Test::Spec::it() as: it CODE\n}; Test::Class::->runtests; diag('Last it() statement.'); }; runtests unless caller;
The Test::Class::Example::Hello::Tests module:
ken@ganymede: ~/tmp/Test/Class/Example/Hello $ cat Tests.pm package Test::Class::Example::Hello::Tests; use base 'Test::Class'; sub test_Hello : Test { print qq{Hello, world! (from Test::Class as: sub test_Hello : Test +\n}; return 1; } 1;
Sample run:
$ pm_class_spec_comb.pl # Hello, world! (from Test::More::diag() as: diag()) Hello, world! (from Test::Spec::it() as: it CODE 1..1 Hello, world! (from Test::Class as: sub test_Hello : Test ok 1 # skip 1 # Last it() statement.
I'll leave you to experiment further.
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Test::Class with Test::Spec's sugar ?
by mascip (Pilgrim) on Jul 14, 2012 at 08:05 UTC |