Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Current behaviorProblemBefore#699, every static field touched outsideclinit block (so-calledmeaningful static fields) was stored inmodelBefore andmodelAfter and accordingly was set (and correspondingly reset for tests isolation) in code generation part. Such behavior led to unexpected for user explicit static field initialiazations - for example, setting publicOptional<Integer>optionalExample(booleanisEmpty) {returnisEmpty ?Optional.empty() :Optional.of(42);} like: setStaticField(optionalClazz,"EMPTY",empty); Such behavior is mostly strange for a user and should be properly fixed - we should not set such static fields with initializers manually. Current colutionAfter merging#699, we do not explicitly set static fields of classes from so-calledtrusted libraries (be default represents JDK packages), accordingly to SolutionsUse concrete values as soft constraintsThe essense of the problem is assigning values for static fields that would be already set in runtime. So, to prevent it we can try to create models for static fields according to theirs runtime values and filter out statics that are equal to runtime values, with the following algorithm:
Propagate reading of static fieldsWe can change a bit sense of themeaningful statics - mark static fields as meaningful only if they affect a result of the method under test. To decide it, we can propagate such knowledge with the following algorithm:
Filter out statics by |
BetaWas this translation helpful?Give feedback.