java - IllegalArgumentException: Invalid conditional statement inside expectation block -
i have problem expectations
block have written in test case:
new expectations() { { mfindhandlermock.findall((model) any, (set<id>) any, false); if (!pwithrealdata) { result = collections.emptyset(); } else { result = palldata; } times = 1; deencapsulation.invoke(mdb, "readsqlquery", withany(string.class)); result = "select * realdata"; times = 1; } };
the test case crashes with:
java.lang.illegalargumentexception: invalid conditional statement inside expectation block
exactly here:
if (!pwithrealdata) {
it's simple boolean
false
in case.
i have absolutly no clue why exception
happens. searched google found nothing helpful.
could me?
from jmockit release notes version 1.14:
enhancement: conditionals , loops trigger exception when found inside expectation recording block, prevent api misuse , encourage simpler tests. see issue #97.
the github issues related this:
in 1 issue state that:
yes, , intended, avoid tests getting complicated when recording expectations. full test not shown, looks me recording specific expectations directly better in case.
in jmockit source can see other types of conditionals , loops throw exception.
in short, jmockit 1.14 onwards not allowed have conditionals (such if statements) , loops in expectation block.
Comments
Post a Comment