Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To complete this assignment: 1 ) Create four ( 4 ) sets of black - box functional unit test cases and unit tests to test

To complete this assignment:
1) Create four (4) sets of black-box functional unit test cases and unit tests to test the following public components of the Reservation class:
a) The constructor & getters methods
b) The setters & getters methods
c) The calculateReservationNumberOfDays() method
d) The calculateReservationBillAmount() method
For each of these four (4) sets complete the following:
a) Create a set of black-box functional unit test cases (composed of Selected Inputs, Expected Result, Actual Result, Pass|Fail) to test the designated public component(s) of the Reservation Class.
b) Using the provided *.jar file, code Java unit tests to execute your test cases and record their Pass|Fail verdicts for the designated public component(s) of the Reservation class.
On the Java command line, compile and execute your single test file (e.g., TestReservation.java) using this single java command (note that you need to specify the *.java extension for your single test file):
java -cp w6.jar TestReservation.java
c) Explain your approach to black-box unit test designated public component(s) of the Reservation class, the steps you followed to create it, and the rationale behind your test cases and their results.
Importing the jar file provided for the assignment just ends with me receiving the error that import cannot be resolved.
import w6.Assert;
public class TestReservation {
public static void main(String[] args){
//Constructor and getter methods
Reservation r1= new Reservation(1, "John Doe", "2024-04-07","2024-04-10");
Assert.assertEquals (1, rl.getGuestID());
Assert.assertEquals ("John Doe", rl.getName());
Assert.assertEquals ("2024-04-07", rl.getStartDate ());
Assert.assertEquals ("2024-04-10", rl.getEndDate ());
//Setter and getter methods
rl.setGuestID(2);
Assert.assertEquals (2, rl.getGuestID());
rl.setName ("Jane Doe");
Assert.assertEquals ("Jane Doe", rl.getName ());
rl.setStartDate ("2024-08-04");
Assert.assertEquals ("2024-08-04", rl.getStartDate ());
rl.setEndDate ("2024-08-06");
Assert.assertEquals ("2024-08-06", rl.getEndDate ());
//Method to calculate the number of days reserved
Assert.assertEquals (4, rl.calculateReservationNumDays ());
//Method to calculate the bill for the reserved number of days
Assert.assertEquals (500.0, rl.calculateReservationBillAmount ());
}
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

Students also viewed these Databases questions