Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Testing without linking to legacy codebase

by MidLifeXis (Monsignor)
on Jun 07, 2016 at 14:16 UTC ( [id://1165078]=note: print w/replies, xml ) Need Help??


in reply to Testing without linking to legacy codebase

Agreed with stevieb on mocking. My goto for this is Test::Mock::Guard. Basically you are replacing some method on a class or object with your own.

my $guard = mock_guard( $original_class, { GetDataFromOldSystem => sub {...}, }, ); $obj = $original_class->new(...); $obj->SomeOtherFunctionThatCalls_GetDataFromOldSystem(...);

Your provided sub would then return some pre-baked values instead of going to the original system.

--MidLifeXis

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1165078]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found