Recommendation type: NullPointerException Thrown
Configurable in Preferences: No
Filter category: Exceptions / assertion errors
UTA displays this recommendation when a NullPointerException has been thrown during the test run. Depending on you code, the following action links may be available:
UTA can detect the a NullPointerException within one source class.
See Exceptions and Assertion Errors for more options that can be displayed for exceptions.
In the following example, the value of customer
is null
:
When the getName
method is called on the customer object, the NullPointerExceprion is thrown:
UTA detects the NullPointerException and displays the following information in the Recommendations view:
You can prevent the NullPointerException from being thrown in one of the following ways:
customer
object to ensure the object value is not null.customer
object. You may need to manually replace the default values UTA generates.getName
method is called on the mocked object.getName
method, which is called on the mocked customer
object.getName
method.@Test(expected=NullPointerException.class)
annotation to the test code. This will prevent UTA from displaying this recommendation in the subsequent test runs.