Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please in java To help you write your tests, you will write several testing utility methods. These methods are meant to help you write your

Please in java
To help you write your tests, you will write several testing utility methods. These methods are meant to help you write your
unit tests. These methods will compare Song, Rating, and Reviewer objects for equality. When writing test cases, you should
create an object with the values that you expect, call the method to be tested to create an object of the same type, then call
your utility method to check if the 2 objects contain all the same values.
Create a class named TestClasses 1 in the tests package (tests.TestClasses1) and write the following methods in that class
(Note: Do not add the @Test annotation to these methods since they are not tests):
compareSongs - Write a method named compareSongs in the tests.TestClasses1 class that:
Takes [references to]2 Song objects as parameters
Returns a boolean that is true if the title, artist, and id of both Songs are exactly the same. The method either
returns false, or fails a JUnit assert, if the Songs do not have all the same values
If the 2 Songs do not have all the same values you can either: return false, or have an assert that fails. This gives
you the option of using assertTrue, assertEquals, etc. in your utility methods instead of returning false when the
test should fail. It is recommended that you write this method with assert statements, then add "return true" as
the last line of the method. The method will never return false, but if any assert fails the test will fail without
reaching your "return true" line. If you chose to not use asserts and instead return false when the Songs are not
identical, be sure to add assertTrue in your test cases when you call this method. (This structure is the same for
all utility methods)
compareRatings - Write a method named compareRatings in the tests.TestClasses 1 class that
Takes [references to]2 Rating objects
Returns a boolean that is true if the rating and reviewerID of both Ratings are exactly the same. The method
either returns false, or fails a JUnit assert, if the Ratings do not have all the same values
compareReviewers - Write a method named compareReviewers in the tests.TestClasses 1 class that
Takes [references to]2 Reviewer objects
Returns a boolean that is true if the reviewerID of both Reviewers are exactly the same. The method either
returns false, or fails a JUnit assert, if the Reviewers do not have the same reviewerID
To help you write your tests, you will write several testing utility methods. These methods are meant to help you write your unit tests. These methods will compare Song, Rating, and Reviewer objects for equality. When writing test cases, you should create an object with the values that you expect, call the method to be tested to create an object of the same type, then call your utility method to check if the 2 objects contain all the same values.
Create a class named TestClasses1 in the tests package (tests.TestClasses1) and write the following methods in that class (Note: Do not add the @Test annotation to these methods since they are not tests):
compareSongs - Write a method named compareSongs in the tests.TestClasses1 class that:
Takes [references to]2 Song objects as parameters
Returns a boolean that is true if the title, artist, and id of both Songs are exactly the same. The method either returns false, or fails a JUnit assert, if the Songs do not have all the same values
If the 2 Songs do not have all the same values you can either: return false, or have an assert that fails. This gives you the option of using assertTrue, assertEquals, etc. in your utility methods instead of returning false when the test should fail. It is recommended that you write this method with assert statements, then add "return true" as the last line of the method. The method will never return false, but if any assert fails the test will fail without reaching your "return true" line. If you chose to not use asserts and instead return false when the Songs are not identical, be sure to add assertTrue in your test cases when you call this method. (This structure is the same for all utility methods)
compareRatings - Write a method named compareRatings in the tests.TestClasses1 class that
Takes [references to]2 Rating objects
Returns a boolean that is true if the rating and reviewerID of both Ratings are exactly the same. The method either returns false, or fails a JUnit assert, if the Ratings do not have all the same values
compareReviewers - Write a method named compareReviewers in the tests.TestClasses1 class that
Takes [references to]2 Reviewer objects
Returns a boolean that is true if the reviewerID of both Reviewers are exactly the same. The method either returns false, or fails a JUnit assert, if the Reviewers do not have the same reviewerID
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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions