Details
Description
The attached test suites for org.apache.commons.lang3.StringUtils.java and org.apache.commons.lang3.CharSequenceUtils.java come from a prototype I have been working on which combines static analysis and automated test generation.
The prototype analyses a specified dependency of a project to identify risky API calls which may potentially lead to runtime exceptions. Runtime exceptions may occur either because
- an API lacks sufficient documentation,or
- usage of the API does not conform to the specification, or
- API wrapper does not indicate the API specification as part of its own specification.
The prototype then automatically generates test cases which show how such exceptions may be triggered.
Observation:
For commons-lang, JDK APIs were analyzed. It seems that the failing methods do not handle the potential runtime exceptions which may or may not have been declared/documented for the JDK APIs they invoke.
Possible fixes:
- The failing methods under test could add internal checks on the values they forward to the JDK APIs.
- The failing methods could handle the exceptions by adding relevant try/catch blocks.
- The failing methods under test could specify the potential exceptions by adding @throws in their documentation/method signatures.
Attachments
Attachments
Issue Links
- relates to
-
LANG-1631 Add short circuits in CharSequenceUtils if a character is not defined
- Resolved