TAPE Test Code Adaptation Plugin for Eclipse Lehmia Kiran Dr. Fakhar Lodhi Wafa Basit Department of Computer Sciences Department of Computer Sciences Department of Computer Sciences NUCES-FAST NUCES-FAST NUCES-FAST Lahore, Pakistan Lahore, Pakistan Lahore, Pakistan [email protected] [email protected] [email protected] Abstract — Refactoring improves the design of software and Extreme Programming (XP) [14] allows the code to change makes it easier to maintain by eliminating code smells. Manual often; consequently unit tests must also be changed. In refactoring is often error-prone and time-consuming. traditional testing, it is a tester who writes the tests but in Refactoring tools available in almost all major object oriented XP it is developers (not testers) who write tests for every programming languages like java, C++, C# etc that provide class they develop. Whenever refactoring is applied on varying degree of automation. The problem with these tools is that they do not support adaptation of unit tests of the code, many test cases fail due to inconsistency with source refactored code resulting in inconsistent unit tests. Unit tests code. The significant amount of developers’ effort is are the only safety net available to developers to verify the required to manually manipulate the testing suite on every system behavior after refactoring. Once these tests get broken single refactoring [15].The process of refactoring is there is no way to describe whether the system preserved its automated by many tools [17, 20, 21, 22]. Eclipse supports behavior or not. In this paper we provide technical details of automated refactoring and provides separate API to perform TAPE (Test code Adaptation Plug-in for Eclipse). This tool not refactoring. But this API only focuses on source and does only automates a few commonly used refactorings but also not adapt test cases, making both inconsistent. supports adaptation of unit tests affected by the refactoring Cost and effort of adapting test cases are very high. process. Using this tool the developers can concentrate more on code development activities instead of resolving consistency Complication of the adaptation increases with complexity of issues between code and unit tests. refactoring applied. In some cases adaptation becomes very complex and test cases have to be thrown away and new test Keywords-Refactoring; Unit testing; Adaptation cases have to develop [19]. Creation and maintenance of test cases are very expansive so it’s not feasible to throw away [8]. The solution to this problem is presented by TAPE I. INTRODUCTION “Test Code Adaptation Plug-in for Eclipse”. Refactoring is the process to change the code, making it TAPE has been especially designed to improve the process easier to understand and cheaper to modify [6]. But it is of refactoring. It is an Eclipse plug-in which adapts test cases important to verify semantic and syntactic correctness of the making it consistent and semantically aligned with the code refactored code. Any modification in code can induce new after applying refactoring. TAPE reduces the cost of bug in the code. Unit testing is the key method used to maintenance of test cases because it makes source code and validate the code after refactoring [16]. Unit test cases in test cases synchronized. Both source code and the test code Object Oriented Paradigm are the programs that test classes come under the owner ship of a developer. If there is change [12]. So, each program is composed of units. Each unit is set in the source code; the associated test code should also be of functions and these units are tested separately and test the adapted accordingly[18].Our plug-in gives sigh of relief to code at lowest level of granularity [13]. Different developers by drastically reducing time and effort of frameworks for unit testing are available [1, 23, 24]; Junit manually resolving the consistency issues between code and [1] is the java plug-in which is used to run the test cases in unit test. the background. It tells about the failure or acceptance of the Section 2 is of literature review which discusses refactoring testcases. Eclipse [17] is the java IDE, which is used to edit, and available tools for performing refactoring. Section3 compile and run the java code. When junit is embedded in contains architecture and implementation details of Test eclipse, test cases can also run on Eclipse. But, junit does Code adaptation plug-in. Before discussing technical details not provide support for writing testcases and developers of TAPE, prerequisite information like refactoring API for have to write the test cases by themselves, this problem is eclipse, plug-in for unit testing "Junit" and "MoreUnit", solved by moreUnit. MoreUnit [5] is an eclipse plug-in that eclipse java plug-in for generation of unit tests are briefly helps in generating automated Junit tests. illustrated. Section 4 contains conclusion and future work. II. LITERATURE REVIEW refactorings out of 72 are supported by net beans. 10 Refactoring is a means to improve the quality of existing refactorings belong to classA and 4 refactorings belongs to code. The main idea behind refactoring is to change the class B. These figures tell us that out of 72 refactorings only code in small steps, while maintaining its external behavior 4 refactorings are those which do not break test code and it [6]. Preserving code behavior means that functionality of the is very less in number. program must be unchanged after refactoring. The process of refactoring can be done manually but it’s very tedious Eclipse supports total 21 refactorings. The tool also and error-prone. Significant amount of work can be reduced implements 8 refactorings other then fowler.17 refactorings and efficiency can be increase by making this process belongs to class A and 4 refactorings belongs to class B. automated [10]. Fowler’s refactoring guidelines provides Only 4 refactorings are those which adapt unit tests in it. road map to perform 72 refactoring [6] but these guidelines Similarly, in IntelliJIDEA 13 refactorings are those, whose are only applicable to production code. To incorporate the guidelines are not provided by fowler and only 4 unit test adaptation in refactoring the Fowler’s guidelines refactorings out of 72 belongs to Class B, which are very for refactoring are not sufficient so extended guidelines to few in number. In CppRefactory there is no refactoring adapt production code and test code are illustrated in [8] and which belongs to class B and in visual Studio.Net only one are followed in TAPE to perform refactoring with unit test refactoring adapts unit test with source. adaptation. III. TAPE [8] categorizes refactoring guidelines into three categories based on their affect on test code and production code. In Eclipse refactoring plug-in has been used as a baseline this paper only the impact of refactoring on unit tests is for TAPE. Find below a short overview of how refactoring considered therefore the type II and III are merged. So, two is done in Eclipse. broad classes of refactoring guidelines are: A. Refactoring in Eclipse A: Refactoring that break test code B: Refactoring that does not break test code Eclipse supports automated refactoring and provides an API for implementing refactoring that can be applied to any of Automated tools are available for refactoring in almost all its workspace elements (e.g. class or method). Eclipse major object oriented programming languages like Java, refactoring is implemented for several languages e.g. Java C++, C# etc. IntelliJIDEA, Eclipse and Net Beans are refactoring tool for java language, CppRefactory and and C++; but only refactoring of Java code [7] is Xrefactory supports refactoring in C++ and to perform highlighted in this paper.Following eclipse IDE snippet shows the types of available refactoring. refactoring in C#, C# Refactoring Tool and C# Refactory are available. Following table shows the total number of refactorings in different tools and the number of refactorings belongs to classes A and B. Table 1: Class A and Class B refactorings of different tools Tool name Refactorings Total Class A Class B Netbeans 14 10 4 Eclipse 21 17 4 IntelliJ IDEA 32 28 4 Cpp 2 2 0 Refactory Figure 1: Refactoring Menu in Eclipse Visual Studio 5 4 1 .NET(C# B. Junit refactoring To test the code after refactoring some testing Tool) mechanism is needed but writing unit tests is a tedious task. The objective is to make process of writing testing code easier and more maintainable [11]. Testing frameworks are Netbeans offers total 14 refactorings. And out of 14, 8 available that automate many aspects of test creation and refactorings are defined by fowlers. So, 8 fowlers’ maintenance [1, 23, 24]. An example of such a framework assist in refactoring the code and adapting test cases in it. is Junit [1]. Following refactorings are discussed in this paper: “JUnit is a unit testing framework for the Java 1. Move method programming language. JUnit has been important in the 2. Inline method development of test-driven development, and is one of a 3. Pull Up method family of unit testing frameworks collectively known as 4. Rename method xUnit that originated with SUnit .”[1] To run the test cases in background Junit has been used, Sometimes adaptation of unit tests turns out to be test but problem of writing test cases remains the same as Junit code refactoring like in ‘move method’ and ‘pull up only runs the test cases and gives output about its failure or method’ refactoring, if the method is moved, the success. To resolve the issue of writing test cases moreUnit corresponding test method will also be moved in test case.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages6 Page
-
File Size-