October 7th, 2011, 01:38 AM
JUnit testing help! pls!
so i have this assignment and I'm a little confused on how and what i am supposed to do with unit testing and where i am supposed to put code in so the test will pass. here is the assignment, which i have done until unit testing.:
Create a new class named Contact in the addressbook package.
The Contact class must have the String properties listed below. Since they are properties, they should have public getters and setters. Note that once you have the instance variables defined, you can used Source | Generate getters and setters... to get Eclipse to automatically add the getters and setters.
The class must have a public constructor with the signature given below. Note that you can get Eclipse to build this method for you by right-clicking in the code view | Source | Generate Constructure Using Fields... In the dialog, select only the lastName, firstName, phoneNumber, and email fields. Click OK.
public Contact(String lastName, String firstName, String phoneNumber, String email);
Copy ContactList.java into your addressbook package.
Refresh your project.
Your AddressBook class (see below) must implement the ContactList interface.
You need to read the comments above each method declaration in ContactList.java to see what each method is supposed to do.
You do not modify ContactList.java. You will be adding your code to AddressBook.java (see below).
In the Package Explorer, select the addressbook package | New | Class.
In the wizard, set the name to AddressBook. Then click the Add (interface) button, and search for ContactList. Check the "Inherited abstract methods" box. Click Finish. Eclipse will create the class and automatically add method stubs that meet the ContactList interface.
Add the unit testing classes. These classes will be used to test the code that you write.
Create a new package in the src folder called sbccunittest. To be clear: sbccunittest should be a child of the src folder, not of the addressbook package.
Add AddressBookTester.java to sbccunittest.
Copy Small.xml to your project's root.
Debug all compilation Errors (see the Problems view). The unit tests can't be run until these errors are fixed.
In the Package Explorer, right-click on the sbccunittest package | Run As... | JUnit Test.
The results of the tests contained in AddressBookTester will be displayed in the JUnit view of Eclipse. In the JUnit view, you can expand the sbccunittest.AddressBookTester item to see which tests were run and their pass/fail status.
Initially, all of the tests will probably fail. However, as you add functionality to the AddressBook class, tests will begin to pass.
Work on AddressBook.getCount(), .getCurrent(), .insertBeforeFirst(), .insert(), and .delete(). When you have them working properly, the testInsertAndDelete test will pass.
Next work on getting testIteratePastEnds to pass.
Continue adding functionality to the AddressBook until all of the unit tests pass (except, perhaps, testSort(), which is extra credit).
The user interface must support the use cases listed below. Do not work on your GUI until all of the unit tests pass (except perhaps testSort(), which is extra credit).
Open a file
The user clicks the open toolbar button.
An open file dialog is displayed, allowing the user to select an address book file (see below for file format).
Clears the current address book entries and replaces them with contacts in the seleted file. Contacts are stored in the same order as in the file. The first contact in the file is dipslayed on the UI.
The user clicks the save toolbar button.
If a file has not been selected by the user (via open file toolbar button), save the data to contacts.xml. Otherwise, use the same filename that the user selected when the file was opened.
The user clicks the next button.
The next contact is displayed.
The user clicks the previous button.
The previous contact is displayed.
The user clicks the previous button.
The first contact is displayed.
The user clicks the last button.
The last contact is displayed.
The user fills out new contact information.
The user clicks the insert button.
The new contact is added after the current contact. The new contact becomes the new current contact.
The user clicks the delete button.
The current contact is deleted. The new current contact is displayed.
The user enters a last name to search for in the search text box.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!