Mining unit test cases to synthesize API usage examples

07/30/2022
by   Mohammad Ghafari, et al.
0

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 representing the usage of such APIs. We compare the output of a prototype implementation of our approach to both human-written examples and to a state-of-the-art approach. The obtained results are encouraging; the examples automatically generated with our approach are superior to the state-of-the-art approach and highly similar to the manually constructed examples.

READ FULL TEXT

page 3

page 4

page 7

page 8

page 9

page 10

page 13

page 16

research
07/01/2023

Automatic Unit Test Generation for Deep Learning Frameworks based on API Knowledge

Many automatic unit test generation tools that can generate unit test ca...
research
11/03/2020

Exempla Gratis (E.G.): Code Examples for Free

Modern software engineering often involves using many existing APIs, bot...
research
02/16/2021

Automatic Detection of Five API Documentation Smells: Practitioners' Perspectives

The learning and usage of an API is supported by official documentation....
research
12/28/2020

API Misuse Detection An Immune System inspired Approach

APIs are essential ingredients for developing complex software systems. ...
research
08/27/2021

An Experimental Analysis of Graph-Distance Algorithms for Comparing API Usages

Modern software development heavily relies on the reuse of functionaliti...
research
03/16/2018

Identifying Components from Object-Oriented APIs Based on Dynamic Analysis

The reuse at the component level is generally more effective than the on...
research
04/25/2017

DeepAM: Migrate APIs with Multi-modal Sequence to Sequence Learning

Computer programs written in one language are often required to be porte...

Please sign up or login with your details

Forgot password? Click here to reset