Instance object of my class under test behavior varies when I tried to mock private method of my class. I have object of my CUT which I am initializing in @Before setup method
@Before
public void setUp() {
cutInstance = new CUT();
and in my test method I mocked CUT by creating local object of CUT
@Test
public void test_someMethod(@Mocked CUT cutInstanceLocal)
then mocking private method of CUT using Expectations API
new Expectations(cutInstanceLocal) {{
Deencapsulation.invoke(cutInstanceLocal, "cutPrivateMethod", value);
result = fakeValue;
}};
now testing the cutMethod(param) which will internally call mocked method.
now on testing, sometimes I got param's value as null, which is weird.
Why it is happening so ?