This proactive recommendation capability can be valuable in many kinds of development projects, including traditional heavyweight projects. It does not, however, exploit all of the opportunities that exist to accelerate software development. In particular, it does not exploit the fact that discovered software components are potentially executable and that test-cases are often written before the implementation code, especially in agile projects. Code Conjurer offers another more advanced search facility, known as test-driven search that leverages these two facts to significantly boost the value of search results. As soon as an executable test has been defined by the developer, Code Conjurer sends this to the Merobase server to find matching components that pass the test. Merobase does this by:
- Working out what interface the test is written against
- Performing a normal search on this interface
- Testing the results to filter out those that match
The resulting set of component recommendations is of much higher value than that generated by regular interface-based matching alone because the components do what the developer has specified; that is, they pass his test.
A developer can decide to write the whole test before initiating a test driven search (as shown in Figure 2) or configure Code Conjurer to search for components within the test/implementation cycle advocated in Extreme Programming . In both cases, Code Conjurer indicates how the search is proceeding (bottom left corner and, optionally, in the other two windows at the bottom). Whenever a candidate component passes the given test, it is highlighted in green using the familiar JUnit convention. If the test is complete, a component that has passed the tests (indicated in green) is fit for purpose and can be inserted directly into the project. If not, the developer can complete the test using the candidate component's interface to check if it behaves as required.
When performing test-driven searches in proactive mode, Code Conjurer is able to suggest candidate reusable components based on partial tests without disturbing the developers normal work and before much of the component has been implemented. It complements Extreme Programming by promoting the reuse of component implementations alongside the traditional approach of building them from scratch. We have, therefore, referred to this approach as Extreme Harvesting in previous papers . Extreme Harvesting extends the extreme programming mantra of "design a little, code a little, test a little" to include "design a little, harvest (i.e. reuse) a little, test a little" as a possible route to successful application development.
Using Code Conjurer it is not only a venue for locating normal reusable components based on tests defined by the developer, it also possible to search for pre-existing tests, as well. When a developer begins writing a test, Code Conjurer can look for previously indexed tests and offer these for reuse.
When Code Conjurer is able to find components that match a developer's tests, it effectively "conjures up" reusable code from "thin air". The user does not have to deviate from his normal development work until a component has been found that does what he is trying to build. Even when no components are found that pass a developer's tests Code Conjurer is able to provide valuable information. By analyzing the search results using various clustering techniques it can create a characteristic picture of the group that includes the typical set of methods. For example, when searching for a matrix component based on an interface with just a multiply method, Code Conjurer can indicate that components with this method typically also support 13 other methods as well, such as swapRows(), transpose() or findPivot(int).
By unobtrusively adding test-driven search capabilities to mainstream development platforms such as Eclipse, Code Conjurer is able to genuinely speed up software development projects, whatever methodology is used. However, agile projects that specialize on small-grained components and writing test cases upfront, stand to gain the most from the tool. Code Conjurer is one small step for test-driven development, one giant leap for agile projects.