Quick Index
Objectives



Description


For this challenge the coder will apply smoke tests to a Rectangle unit (class) in an effort to look for showstopper bugs.

The coder is provided with:


The challenge is to use the unit test to identify bugs, and then resolve the bugs. A "bug summary" must be prepared.

Good luck coder!

Provided Code



Unit (Model)


For this example, we will be testing a unit named Rectangle.

The Rectangle class summary and key method summaries are shown below. We will use these summaries when coding the tests.

Rectangle Structure
class name: Rectangle
access: public
package: model.shapes
Rectangle Method Headers
The smoke tests exercise the following methods:
/** Returns new Rectangle object with passed lat and long values */
public static Rectangle fromUpperLeftWidthHeight(int left, int top, int w, int h)

/** Returns new Rectangle object with upper left (0, 0) and dimensions = 0 */
public static Rectangle newInstance()

/** Returns nice display string for this Rectangle */
public String toString()

Point Method Headers
Pertinent method headers for the Point type are shown below (just in case you need them for bug fixes).
/** Returns new Point with x and y set from params */
public static Point fromXY(int aX, int aY)

/** Returns new Point at origin (0, 0) */
public static Point newOrigin()

/** Returns "nice string" of this Point */
public String toString()



Project Directory Structure


Here is the project directory structure with primary players noted.

Note that classpath (Java) is also called build path (Eclipse) or source folder (IntelliJ).
+---srcclasspath
| +---model | | +---shapes | | \---Rectangle.javaUnit | | \---FullName.java | +---test | | +---cases | | +---shapes | | \---RectangleTest.javaUnit
Test
| | \---rectangle-bug-summary.txtBug summary
starter file


Challenge Rules



Note: The referenced "example" is the example from this chapter

Expected Unit Test Output


Once all the showstopper bugs have been identified and fixed this is the expected output when running the unit test.

-- test_newInstance --
(left, top, right, bottom) = (0, 0, 0, 0)

-- test_fromUpperLeftWidthHeight --
(left, top, right, bottom) = (100, 50, 110, 55)


Bug Summary



Note: The referenced "example" is the example from this chapter

Deliverable (Output)


The deliverable (product) for this challenge is the file "rectangle-bug-summary.txt".