Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Order of startup methods with Test::Class

by Ovid (Cardinal)
on Oct 09, 2011 at 15:02 UTC ( #930476=note: print w/replies, xml ) Need Help??

in reply to Order of startup methods with Test::Class

This is a common anti-pattern I see in Test::Class code. If you have a subclass, you should view this as a more specific instance of your parent class. Your startup/setup/teardown/shutdown methods (which I refer to as "test control methods") shouldn't rely on a prefix hack, as you rightly pointed out. Instead, you override them and your subclass calls the parent class's method as appropriate:

sub setup : Tests(setup) { my $test = shift; $test->SUPER::setup; # my setup code here }

With this approach, you have complete control over the order of how things run and you don't have to worry about prefixes.

You might want to read my tutorial on Test::Class, in particular the test control methods section.

Replies are listed 'Best First'.
Re^2: Order of startup methods with Test::Class
by chrestomanci (Priest) on Oct 09, 2011 at 20:21 UTC


    Thank you, that was the answer I was looking for.

    All I have to do is name all my setup methods the same, and subclass where appropriate.

      Happy to have helped. By the way, I noticed you're using my Test::Most module. Since you're also using Test::Class, you might also find my Test::Class::Most module handy.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://930476]
[ELISHEVA]: Beat me to it!
[erix]: ( but you know how to perldoc DBI::CSV, right? )
[ELISHEVA]: yes - I set "f_encoding"
[erix]: still doesn't work?
[afoken]: sorry, forget File::BOM. I did not see DBD.
[ELISHEVA]: perldoc - of course
[erix]: hm, where's tux when you need him?
[ELISHEVA]: what's curiouser is that the underlying Text::CSV_XS appears to be BOM-friendly
[afoken]: DBD::CSV has a csv_class attribute. You could subclass Text::CSV_XS to handle BOMs, e.g. through File::BOM.
[ELISHEVA]: Text::CSV_XS already can handle boms - see its detect_bom flag

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2017-05-28 20:24 GMT
Find Nodes?
    Voting Booth?