1 / 15

Design and Method

Design and Method. Testing and Test Harness. Objectives. Set up a test plan for a simple Java class. Distinguish basic from volume test plans for more elaborate Java classes. Draw a (class) diagram for a state to be displayed. Plan a test harness for a given functional interface.

hubert
Download Presentation

Design and Method

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Design and Method Testing and Test Harness J. B. Wordsworth: J5DAMTTH

  2. Objectives • Set up a test plan for a simple Java class. • Distinguish basic from volume test plans for more elaborate Java classes. • Draw a (class) diagram for a state to be displayed. • Plan a test harness for a given functional interface. • Know what files to submit. J. B. Wordsworth: J5DAMTTH

  3. Class testing • Use the sequence diagrams to determine the collaboration hierarchy . • Test the classes starting at the ends of the hierarchy. • Write a driver for the class to be tested. • Use general methods to develop the driver and the test cases. J. B. Wordsworth: J5DAMTTH

  4. The Paper class • Attributes: • num : an integer • customers : a HashTable, String to null • Constraints: • num is the size of customers. • Methods: • Paper () num, customers := 0, empty. • addOrd (String cn) adds cn to the keys of customers and increases num by 1. • delOrd (String : cn) removes cn from the keys of customers and decreases num by 1. • showOrds () returns an Enumeration of the keys of customers. • getNum () returns num. J. B. Wordsworth: J5DAMTTH

  5. Test plan for Paper • Test scheme: • Paper () • getNum () {0} • addOrd (“Jim”) ; getNum () {1} • addOrd (“Pat”) ; addOrd (“Les”) ; getNum () {3} • delOrd(“Pat”); getNum () {2} • showOrds (); display list; {“Jim”, “Les”; or “Les”, “Jim”} • Documentation: • Test ID, Message, Expected output J. B. Wordsworth: J5DAMTTH

  6. Test plan for Newsagency - basic • Create an initial Newsagency • Exercise the methods that do not change the state • Test ID, Test message, Expected output • Add a customer • Exercise the methods that do not change the state • Add a paper • Exercise the methods that do not change the state • Add an order • Exercise the methods that do not change the state J. B. Wordsworth: J5DAMTTH

  7. Displaying the state State 0..* 0..* Customer details Paper details 1 etc. Customer name 1 1 Address Order details 0..* Paper name J. B. Wordsworth: J5DAMTTH

  8. A state displayed Customers: Jim at The Lodge has orders for: Times Daily Telegraph Jane at 5 The Crescent has orders for: Daily Mail Times CLNH at Cedar Lawn has orders for: Sun Times Papers: Times has 3 copies Daily Mail has 1 copy Daily Telegraph has 1 copy Sun has 1 copy J. B. Wordsworth: J5DAMTTH

  9. Test plan for Newsagency - volume • Create an initial Newsagency. • Set up a more elaborate state with customers, papers, and orders (external file?). • Display the state. • Choose something to test. • While there are things to test: • Exercise a method that needs testing. • Display the state. • Choose something else to test. • Documentation: • Test ID, Message, Expected output, Expected change of state J. B. Wordsworth: J5DAMTTH

  10. Documenting test cases • Test case ID • System configuration being tested • FID function being tested • Initial state • Input values • Expected final state • Actual final state • Expected output • Actual output • Pass or fail? J. B. Wordsworth: J5DAMTTH

  11. Test harness structure • Present one menu item for each FID function. • Add menu items to view/set state. • Program one switch with a case entry for each menu item: • set values in state • accept input arguments • run the function • display outputs and state change. J. B. Wordsworth: J5DAMTTH

  12. Test harness class public class TestHarness { public static void main(String args[]) throws Exception { TestHarness th = new TestHarness(); try { th.run(); } catch (Exception e) { System.out.println(e); } th.quit(); } J. B. Wordsworth: J5DAMTTH

  13. Test harness usage • input from keyboard, output to screen • input from keyboard, output to a file • input from file, output to a file J. B. Wordsworth: J5DAMTTH

  14. Project files • *.java for each back-end class • *.java for state (container class) • Wrapped*.java • FIDo.java (interface) • TestHarness.java • *.dat (to hold the data) J. B. Wordsworth: J5DAMTTH

  15. Summary • Test plans should exercise all the functions and states of a product. • Class testing begins at the bottom of the collaboration hierarchy. • Displays of state before and after a test might need special methods. • A test harness is designed to allow its user to exercise the functions of an interface. J. B. Wordsworth: J5DAMTTH

More Related