Software Testing, Verification and Validation Karl J. Lieberherr COM 3220 Spring 1999 =========================================================================== Due date: April 29, 1999 This assignment is stored in file $TVV/hw/4 in file assign.txt On CCS Northeastern machines, TVV=/home/lieber/.www/com3220/ On the WWW, TVV = http://www.ccs.neu.edu/home/lieber/com3220/sp99 ========= The DJ home page is: http://www.ccs.neu.edu/research/demeter/DJ/ The AP Library home page is: http://www.ccs.neu.edu/research/demeter/AP-Library/ Connection between DJ and AP Library: DJ uses the AP Library. When you test DJ you test the code in the AP Library. A good question: is testing DJ testing all of the AP Library? The AP Library Specification home page is: http://www.ccs.neu.edu/research/demeter/biblio/strategies.html ASSIGNMENT 4 ============================================================= TESTING of a Java Productivity tool:DJ ============================================================== PART 1: ======= Time can be an important factor in testing. Determine through testing how much slower a DJ fetch is than a hand-coded fetch. Hint: Call System.currentTimeMillis() before and after the code that you're timing. A DJ fetch is expected to be considerable slower because it relies on Java reflection. This analysis is important for testing because a result that is too late can be as useless as a wrong result. Answer the same question for gather an traverse. How much slower is a DJ gather than a hand-coded gather? How much slower is a DJ traverse than a hand-coded traverse? The answer to those questions is probably dependent on the example you choose. Therefore choose three different examples and take the average of the three. PART 2: ======= Write a program to test DJ as described below: The purpose of this program is to read in a description of nested containers and to build a Java object. The program then checks whether each container satisfies its capacity restriction. Example: Consider the following container description ( //begin container 1 apple 1 //item ( //begin container 2 pencil 1 //item ( //begin container 3 apple 1 //item 1) //capacity orange 1 1) //capacity orange 1 kiwi 1 5) //capacity ================= Container 2 is over capacity since it contains three items with a total weight of 3, but the capacity is one. Container 1 is also over capacity. It contains 6 items with a total weight of 6, but the capacity is 5. Container 3 is within capacity. For each container which is over capacity, the program should print a message of the form: total weight 2 but limit is = 1 OVER CAPACITY Use constructor calls to build the container objects; don't write a parser. PART 3: ======= In hw 3 you did not have enough time to write enough test cases. Continue that work now. To test DJ further write a method float average(TraversalGraph tg) for a class A. The method finds all B-objects reachable from an A-object following tg and sums (=s) the value of instance variable val at each B-object and it counts the number of B-objects (=c). The method returns s divided by c. Strategies allow two kinds of syntax. Do both work? Do they have the same behavior? Test the following features of strategies: to-stop, only-through, and the wild-card feature. For example, "from Company to *" means: visit all nodes reachable from Company.