论文标题

采矿单元测试用例综合API使用示例

Mining unit test cases to synthesize API usage examples

论文作者

Ghafari, Mohammad, Rubinov, Konstantin, K, Mohammad Mehdi Pourhashem

论文摘要

软件开发人员研究和重复使用现有的源代码,以了解如何正确使用应用程序编程界面(API)。但是,手动为给定的API手动找到足够和足够的代码示例是一种困难且耗时的活动。查找或生成示例的现有方法假定使用API​​的一组合理的客户端代码的可用性。此假设不适合新发布的API库,非智能使用的API或私人库。在这项工作中,我们重新使用了自然存在于测试代码中的重要信息,以避免其他端源代码源不可用时缺乏API的使用示例。我们提出了一种方法,用于自动识别每个单元测试案例中最具代表性的API用途。然后,我们通过提取代表该API使用的相关陈述来开发一种合成API使用示例的方法。我们比较了我们对人写的示例的原型实施和最先进的方法的原型实现的输出。获得的结果令人鼓舞;使用我们的方法自动生成的示例优于最先进的方法,并且与手动构造的示例高度相似。

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.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源