Testing local scoped object with mockito without refactoring

Posted by supertonsky on Stack Overflow See other posts from Stack Overflow or by supertonsky
Published on 2012-08-28T09:37:03Z Indexed on 2012/08/28 9:38 UTC
Read the original article Hit count: 150

Filed under:
|
|
|
|

Say I have the following code:

public class ClassToTest
{
    AnotherClass anotherClass;

    public void methodToTest( int x, int y )
    {
        int z = x + y
        anotherClass.receiveSomething( z );
    }
}

public class AnotherClass
{
    public void receiveSomething( int z ) {.. do something.. }  
}

I want to make assertion on the value of the variable z. How do I do this? Variables x, y, and z could be some other Java class types, and I just used "int" for simplicity.

© Stack Overflow or respective owner

Related posts about java

Related posts about junit