Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program Description: This assignment will give you practice writing unit tests. You are to write a set of unit tests for the provided Circle class.

Program Description:
This assignment will give you practice writing unit tests. You are to write a set of unit tests for the provided
Circle class.
Your unit tests must be written as JUnit 5 tests. The unit testing lecture slides and the Point class tests
developed during class will provide explanations and examples of how to write unit tests. The lecture
slides include links to additional information online. An internet search for tutorials or examples of unit
testing might help you find additional useful sources of information.
Your unit tests must pass and provide complete code coverage of the Circle class. Run the code
coverage tool to check that your tests provide complete code coverage of the Circle class.
Your unit tests should not produce any console output when run. All results of the tests should be
reported by using JUnit assertions as demonstrated in class.
A correct set of unit tests should expose a bug in the Circle class. This means that your unit tests must
include at least one test that would fail on the provided code, but will pass after you identify and correct
the 'bug'. So, when you discover the bug, correct it and leave your test in place.
Implementation Guidelines:
You must not change any code in the Circle class except to correct the one bug mentioned previously.
Place your unit test class in the 'tests' package.
Hints and Suggestions:
Each unit test should test a single method of the Circle class. Each unit test ideally should have only a single
JUnit assertion or test a single exception. This does not mean that the Circle class and your test class will
necessarily have the exact same number of methods. It may be possible to achieve complete code coverage of
the Circle class without writing tests for every method of the Circle class (this will be true because you will use
some methods of the Circle class to help test other methods). In some cases you may need to write several test
methods in your test class to thoroughly test a single method of the Circle class. Name each of your test
methods appropriately so that the name clearly indicates which Circle class method is being tested.
NOTE: The toString() method of the Circle class internally calls toString() in the Point and Color classes. A call
toString () on the default black unit circle centered at the origin would return the following String:
Circle [radius=1.00, center=Point2D.Double[0.0,0., color=java.awt.Color r=,g=,b=0]
(This is correct output, not a bug!)
Stylistic Guidelines:
You will be graded on program style, which includes:
use of descriptive method and variable names
Javadoc comments on your test class and on every constant, field, and method in your test class
Notice that the provided Circle class produces no warnings from the plugin tools. Be careful to write your
unit test class in a way which minimizes warnings from the tools. Ideally your unit tests should produce no
warnings. If you have questions about what a particular warning means, and a quick online search doesn't
help, ask about it as soon as possible.
Remember to include a non-javadoc header comment at the beginning of your test class with some basic
information, in addition to full Javadoc comments. Examples of acceptable file header comments and of
Javadoc comments appear in the Circle class and in the Point class code example from lecture.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions