Mining unit test cases to synthesize API usage examples
Mohammad Ghafari, Konstantin Rubinov, and Mohammad Mehdi Pourhashem K

TL;DR
This paper presents a method to automatically extract and synthesize API usage examples from unit test cases, aiding developers in understanding and using APIs when client code is unavailable.
Contribution
The authors introduce a novel approach that leverages test code to generate API usage examples, outperforming existing methods and reducing the need for manual example collection.
Findings
Automatically generated examples are highly similar to manual ones.
The approach outperforms the state-of-the-art in quality.
It effectively synthesizes API usage from test code.
Abstract
Software developers study and reuse existing source code to understand how to properly use application programming interfaces (APIs). However, manually finding sufficient and adequate code examples for a given API is a difficult and a time-consuming activity. Existing approaches to find or generate examples assume availability of a reasonable set of client code that uses the API. This assumption does not hold for newly released API libraries, non-widely used APIs, nor private ones. In this work we reuse the important information that is naturally present in test code to circumvent the lack of usage examples for an API when other sources of client code are not available. We propose an approach for automatically identifying the most representative API uses within each unit test case. We then develop an approach to synthesize API usage examples by extracting relevant statements…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Software Engineering Techniques and Practices · Software System Performance and Reliability
