Mining unit test cases to synthesize API usage examples

Ghafari, Mohammad; Rubinov, Konstantin; Pourhashem K., Mohammad Mehdi (2017). Mining unit test cases to synthesize API usage examples. Journal of software: evolution and process, 29(12), e1841. Wiley 10.1002/smr.1841

[img] Text
07884674.pdf - Published Version
Restricted to registered users only
Available under License Publisher holds Copyright.

Download (95kB) | Request a copy

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.

Item Type:

Journal Article (Original Article)

Division/Institute:

08 Faculty of Science > Institute of Computer Science (INF)
08 Faculty of Science > Institute of Computer Science (INF) > Software Composition Group (SCG) [discontinued]

UniBE Contributor:

Ghafari, Mohammad

Subjects:

000 Computer science, knowledge & systems
500 Science > 510 Mathematics

ISSN:

2047-7481

Publisher:

Wiley

Language:

English

Submitter:

Oscar Nierstrasz

Date Deposited:

11 Apr 2018 11:57

Last Modified:

05 Dec 2022 15:11

Publisher DOI:

10.1002/smr.1841

BORIS DOI:

10.7892/boris.113126

URI:

https://boris.unibe.ch/id/eprint/113126

Actions (login required)

Edit item Edit item
Provide Feedback