Homework Assignment 4

Testing Your Auction Program


CS 2530
Intermediate Computing


Due: Thursday, September 27, at 8:00 AM


Introduction

You will not implement new objects for this assignment. Instead, you will create a set of automated tests for the two small classes that you wrote for Homework 3, using the JUnit tool we saw in Session 10.

For Homework 3, you wrote a driver program to demonstrate your Bid and Auction classes. You can use the auctions you created there as a starting point for your JUnit tests. As we saw in class, though, our JUnit test methods will be small, typically testing just one feature, and will use assertions that JUnit can verify automatically. So you will have to decompose your demo main() into several parts.

Here are some items that might help you with the assignment:

Note: I will add specific bullets to the tasks below to help guide you toward a complete set of tests. Check back periodically to see if I have added a hint you can use. I suggest that you do not wait for all the hints before starting! That will not leave you enough time to finish the assignment, and the hints will not be a complete set anyway.



Tasks

Implement a set of unit tests for your simple auction program.

  1. Write tests for the Bid class.

    Place your tests in a class names BidTests.java.

    Your tests should include:

    Here is a free test to get you started:

             public void testHigherBidThan() {
               Bid eugene = new Bid( "Eugene",  50, 2000 );
               Bid mary   = new Bid( "Mary"  , 100, 2000 );
               assertFalse( eugene.higherBidThan(mary) );
               assertFalse( mary.higherBidThan(eugene) );
             }
    


  2. Write tests for the Auction class.

    Place your tests in a class names AuctionTests.java.

    Your tests should include:

    Here is a free test to get you started:

             public void testExecuteWithOneBid() {
               Bid     eugene  = new Bid( "Eugene",  50, 2000 );
               Bid[]   single  = { eugene };
               Auction auction = new Auction( 80, single );
               assertEquals( eugene, auction.execute() );
             }
    

If in the course of testing your Bid and Auction classes, you discover bugs, don't worry. That means your testing has proven valuable. You may fix the class containing the error and submit it along with your tests. If you do so, be sure to document the changes you made in the Bid or Auction class, both in the header block (in a MODIFIED BY section) and at the point of change in the code.



Deliverables

By the due date and time, submit these files:

Be sure that your submission follows all homework submission requirements.



Eugene Wallingford ..... wallingf@cs.uni.edu ..... September 22, 2012