Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re (tilly) 1: Nested Classes

by dcorbin (Sexton)
on Mar 06, 2001 at 22:09 UTC ( #62525=note: print w/ replies, xml ) Need Help??


in reply to Re (tilly) 1: Nested Classes
in thread Nested Classes

Thanks. I think that the might achieve what I was after. Since there was some confusion about what I really want to do, and why, I'll try to give you an example, but I'm going to have to show it in pseudo-java.

public class Foo { public void doSomething(Bar bar) { ... } }
now, I want to write code that tests Foo.doSomething. I want that test to be independent of any problems that Bar might have. So, I write this...
public class FooTest { testDoSomething() { class MockBar extends Bar { // code to simulate a "Bar" } ... bar = new MockBar(); foo = new Foo(); foo.doSomething(bar); // check that the right things happened to bar } }


Comment on Re: Re (tilly) 1: Nested Classes
Select or Download Code
Replies are listed 'Best First'.
Re (tilly) 3: Nested Classes
by tilly (Archbishop) on Mar 06, 2001 at 22:22 UTC
    Before going further, you might want to give Test::Unit a shot and see if it will work for you.
      Test::Unit is simply a framework. It doesn't change HOW you write the actual code that does the testing. But thanks for the pointer.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2015-07-29 07:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls