You can mock out the functions that are legacy (disclaimer: I'm the author of Mock::Sub. There are several other similar distributions. Unfortunately, it doesn't look like I included a SEE ALSO section in this cut, but searching meta for "mock" should list a few).

Code untested. Mock::Sub can also return values, or perform side effects. Peruse the docs.

use warnings; use strict; use Mock::Sub; use Test::More; my $mock = Mock::Sub->new; my $complicated_function = $mock->mock('Old::Codebase::complicated_function'); { my $new_obj = New::Codebase->new; $new_obj->do_something_with_old_code(); is ( $complicated_function->called, 1, "legacy method called ok" ); is ( $complicated_function->called_count, 3, "legacy method called proper num times" ); my @called_with = $complicated_function->called_with; is ( $called_with[0], 'param', "legacy method called with proper param" ); $complicated_function->reset; } done_testing();

In reply to Re: Testing without linking to legacy codebase by stevieb
in thread Testing without linking to legacy codebase by Anonymous Monk

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.