Is it possible to inspect local variables of a method in JMockit?
Source
void foo(){
boolean isPresent = false;
/// ... something here sets isPresent
}
Test
can I check the value of isPresent at the end of call of foo() using JMockit?
Rather than trying to do some obscure mocking mechanism. Try refactoring the code to something that you can test:
void foo(){
boolean isPresent = isPresent();
}
boolean isPresent(){
....
}
Also, consider this. If the variable's value never escapes the method and does not cause some other effect (which should be testable), why try to test it? Or why is it even there? Testing that a method scope variable's value is x has no value. Testing that the method resulted in y because the variable was x has value.