We use cookies to improve your experience with our site.

测试驱动的构件功能提取

Test-Driven Feature Extraction of Web Components

  • 摘要: 1、研究背景:
    Web应用中存在着大量相似功能,为此研究人员开发出了Web构件来将常见功能封装为组件以简化软件开发。但目前的Web构件包含的功能过多,在用户需要细粒度地复用某个功能时,往往由于缺乏对应的API调用而使得复用过程由手工完成。
    2、目的:
    本文旨在提供一种细粒度的Web构件功能复用方法,通过用户对功能进行规范化地指定,我们的方法能够自动地从Web构件的实现中抽取出需求功能对应的代码实现,方便用户进行细粒度地功能复用。
    3、方法:
    本文提出了一种测试驱动的Web构件功能复用方法,我们将用户需求以测试的形式来进行规约,将抽取结果对需求的满足程度用测试通过率来反映。我们衡量用户需求的测试一方面来源于构件在开发过程中自带的功能测试,另一方面我们基于录制重放的思想将用户在构件上的操作场景转换为GUI测试,也作为对用户需求的规约。我们提出了一种分层的遗传算法,用来从源代码中提取出可通过所有给定测试,并尽可能拥有更少代码量的结果。
    4、结果:
    在与现有的功能提取工作对比下,我们的方法能够正确完成出8个网页与10个Web构件的22个功能提取任务。并相对于已有工作拥有更少代码量的提取结果。而在与人工抽取功能的代价对比上,实验人员使用我们的方法能够显著减少时间花费,且我们的方法能够得到比人工结果代码量更少的结果。同时,我们对抽取结果的检查发现,我们的方法侧重于提取出只与特征有关的代码,而会忽略其它保证程序鲁棒性和自适应性等的语句。
    5、结论:
    实验结果表明,我们的方法能够正确地提取出满足用户需求的代码。相对于手工提取结果和目前的特征提取方法得到的结果,我们方法得到的结果拥有更少的代码量。并且,用户使用我们方法的代价远少于手工进行功能提取的代价。

     

    Abstract: With the growing requirements of web applications, web components are developed to package the implementation of commonly-used features for reuse. In some cases, the developer may want to reuse some features which cannot be customized by the component's APIs. He/she has to extract the implementation by hand. It is labor-intensive and error-prone. Considering the widely-used test cases which can be useful to specify the software features, a test-driven approach is proposed to extract the implementation of the desired features in web components. The satisfaction of the user's requirements is transformed into the passing rate of user-specified test cases. In this way, the quality of the extraction result can be evaluated automatically. Meanwhile, a record/replay-based GUI test generation method is proposed to ensure that the extraction result has the correct GUI appearance. To extract the feature implementation, a hierarchical genetic algorithm is proposed to find the code snippet that can pass all the tests and has the approximate smallest size. We compare our method with two existing feature extraction methods. The result shows that our method can extract the correct implementation with the minimum size. A human-subject study is conducted to show the effectiveness and weaknesses of our method in helping users extract the features.

     

/

返回文章
返回