You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For now, the engine considers method invocations or field access on null values as producing NullPointerException. Previously in #226 such NPE checks were disabled for final fields from library classes because it often leads to the generation of tests with exceptions that are unexpected for a user with high usage of Java reflection. It is suggested to extend such a strategy to non-public fields from library classes too, for the same reasons.
Disabling NPE branches for non-public fields (and for final fields as well) affects the fields declared in library classes. While it is OK for JDK classes, it also prevents NPE checks for any third-party libraries, including potentially buggy code. Protected fields may be initialized to null by derived classes as well by any users of these classes using existing constructors or static methods. If the class does not perform necessary checks, NPE may be thrown.
Attached file: a sample project with a (buggy) library dependency packaged as a jar.
Description
For now, the engine considers method invocations or field access on null values as producing
NullPointerException
. Previously in #226 such NPE checks were disabled for final fields from library classes because it often leads to the generation of tests with exceptions that are unexpected for a user with high usage of Java reflection. It is suggested to extend such a strategy to non-public fields from library classes too, for the same reasons.Expected behavior
Consider generating tests for such a method:
Only such 3 tests are expected by user:
But for now, UtBot also generates at least 2 such tests:
These tests SHOULD NOT be generated (in the plugin, at least).
Environment
No mocks, Java.
Potential alternatives
Unknown.
Context
We can possibly lose some branches with such disabling.
The text was updated successfully, but these errors were encountered: