FAST: an Eclipse Plug-In for Test-Driven Reuse Diplom Thesis
Total Page:16
File Type:pdf, Size:1020Kb
FAST: An Eclipse Plug-in for Test-Driven Reuse Diplom Thesis by Monika Krug presented at Chair of Software Technology Professor Colin Atkinson, Ph. D. Department of Mathematics and Computer Science University of Mannheim September 2007 II Abstract FAST: An Eclipse Plug-in for Test-Driven Reuse The code search engines that have emerged over the last few years, in particular merobase.com, simplify the task of finding software components on the Internet based on their interfaces, e. g. Java classes by their method signatures. However, matching signatures do not ensure that the discovered components do what the developer expects from them, i. e. that they are semantically correct. The goal of this thesis is to develop the FAST (Fully Automated Search and Test) Eclipse plug-in that will support Test-Driven Reuse, also known as Extreme Harvesting. FAST will parse the JUnit test case written by the developer at the beginning of the development cycle and find and download Java classes that fit its syntax, i. e. have the right method names, parameter and return types. The plug-in will then run the JUnit test case on each class that was found to determine which of them really do what the developer needs them to do and which ones only happen to fit syntactically. That way Agile Development and reuse come together. III IV Content 1 Introduction....................................................................................................................... ..................1 1.1 Motivation.................................................................................................................. .................1 1.2 Task....................................................................................................................... ......................1 1.3 Structure................................................................................................................... ...................1 2 Agile Development.................................................................................................................. ............2 2.1 Extreme Programming (XP)........................................................................................ ................3 2.2 Crystal Family............................................................................................................ .................4 2.3 Dynamic Systems Development Method (DSDM).............................................................. ........5 2.4 Scrum................................................................................................................... .......................5 2.5 Pragmatic Programming.............................................................................................. ................6 2.6 Agile Modeling................................................................................................................... .........6 2.7 XBreed................................................................................................................ ........................7 2.8 Can Open Source Development Be Agile?................................................................ ..................8 2.9 Test-Driven Development (TDD)............................................................................ ..................10 2.10 JUnit...................................................................................................................... ..................13 3 Reuse................................................................................................................................... ..............15 3.1 Recall and Precision........................................................................................... .......................17 3.2 Repositories.................................................................................................................. .............18 3.3 Source Code Search Engines.................................................................................... .................21 4 Test-Driven Reuse.................................................................................................... .........................33 4.1 Categorization and Evaluation of Test-Driven Reuse........................................ ........................42 4.2 Integrated IDE Support for Reuse............................................................................................ ..47 5 The FAST Plug-in...................................................................................................................... ........50 5.1 What FAST Does............................................................................................................ ...........50 5.2 Overview over the Architecture.................................................................................... .............53 5.3 The Parser: Determining Interfaces from Test Cases.............................................. ...................53 5.4 Interaction with Merobase....................................................................................... ..................58 5.5 Creating a Plug-in............................................................................................................. .........59 5.6 Creating Projects Programmatically................................................................... .......................61 5.7 Running the JUnit Test Cases Programmatically...................................................... .................62 5.8 Non-proactiveness of FAST.................................................................................................... ...62 6 Evaluation of the Plug-in..................................................................................................... ..............64 6.1 Parser Tests...................................................................................................................... ..........64 6.2 Complete Tests................................................................................................. .........................73 7 Conclusion................................................................................................................................... ......87 7.1 Future Work for the FAST plug-in.................................................................................. ...........88 7.2 Future Work for Component Search Engines.......................................................................... ...89 V VI 1 Introduction 1.1 Motivation Agile Development and reuse both aim to enhance productivity and code quality, and there is little doubt that they both achieve these goals [54] [14]. So far they have been considered complementary, if not opposite concepts, because the lack of documentation and other non-code artifacts in Agile Development seems to preclude reuse [2]. It would be useful to bring the two together and shorten development time even further, thus saving a lot of money in software production, as the software industry is one of the few that almost exclusively rely on manpower. The higher code quality will save bug-fixing costs. Also in a non-commercial open-source environment, avoiding “reinventing the wheel” [55] will produce higher quality software and save the scarce resource of development time during the free time of the volunteer programmers, therefore resulting in more free software within the same time. The emergence of code search engines over the past few years has made it easier to find existing software components. Yet still there is little reuse. When the developer does not anticipate the existence of a component, he or she will not bother to start up a code search engine and formulate a query. This would be a distraction from his or her current train of thought or developing activity, therefore no attempt of reuse is made [11] [46] [50]. The correct formulation of the query may be another hurdle [7]. Additionally, when a large number of components fit the query, it can be cumbersome to manually download the components found by the search engine and test them one-by- one to find those that really do what the developer wants and don't only happen to have matching signatures. So what is needed to enable Test-Driven Reuse and thus bring Agile Development and reuse together is integrated support in the development environment [4] [7], here Eclipse, to retrieve components that fit a test case with only a few mouse-clicks, and have those components tested automatically. 1.2 Task The task was to develop an Eclipse plug-in that would parse a JUnit test case and determine the names, parameter and return types of the methods which the not-yet-developed Java class under test needs to have, formulate a suitable search query and send it to merobase.com, download the classes that are found, generate and adapter class if necessary, compile the downloaded classes and run the JUnit test case on those that compile successfully. 1.3 Structure As this thesis is about bringing Agile Development and reuse together, it will begin with background information and previous research on Agile Development on the one hand, in particular of course Test- Driven Development, and reuse on the other hand, in particular repositories and code search engines. Then it will explain how the two come together in Test-Driven Reuse, also called Extreme Harvesting. The remainder of this thesis will be about the FAST plug-in, its evaluation and possible future development. 1 2 Agile Development Agile or lightweight development methods