mercredi 24 août 2016

Test perl sub without instantiating whole file

Given a perl file with something like this:

sub new {
    my $package = shift;

    my %params = @_;
    tons_of_other_initializers(%params);

}

sub simple_thing{

   print "hello";
}

How would I go about testing only simple_thing() without having to do all the initialization for the "object" ?

(The initialization includes a bunch of config files, setting up various data structures (that are mocked out for the test) and calls to external packages thus I really really don't want to run new)

Aucun commentaire:

Enregistrer un commentaire