This is the first time am trying to use reflection for unit testing and I had this doubt.
Class Example {
public static Map<Something, Something> someMethod()
{
int temp = -1;
//Some implementation which might change the value of temp
//depending on other cases
if(temp == -1)
//Do something and return something
else
//return null
}
}
Now in the above snippet, I can get the initial value of the variable temp
using reflection. I wanted to know, if the value of the variable changes while execution of the code how can I get the new value of temp
? Am a total newbie to reflection so if this sounds silly please tolerate.
P.S The actual code am testing is not such a simple one. I have a feeling that I cannot unit test the last if
condition without using reflection or powermock.