Question
Retrieve WidgetOrderYourLastName (from Topic 3). Create a JUnit Test case to test your method. Write three tests using the data and results below (note that
Retrieve WidgetOrderYourLastName (from Topic 3). Create a JUnit Test case to test your method. Write three tests using the data and results below (note that you will need to come up with one of your own tests, as only two are provided).
A hint: You can give your assertEquals method some leeway so you don't need the exact values by using this method:
assertEquals(double expected, double actual, double delta); Asserts that two doubles or floats are equal to within a positive delta.
If you ran your methods (with the main method without the printf( ) or DecimalFormat), you'll see that you get several decimal points. One way that we can account for small differences is by giving the assertEquals method a delta - 0.01. This means that if the return result is within 0.01 of the expected value, return true. The assertion method would look something like:
assertEquals(expected, actual, 0.01);
Create a JUnit test case to test your newly created method. Use the test data below to confirm you are receiving the correct values.
Test Data #1 | Test Data #2 | Test Data #3 |
Enter the number of widgets purchased: 5
------------------------ Order Total: $54.70 | Enter the number of widgets purchased: 8
------------------------ Order Total: $87.52 | You create |
Submit the WidgetOrderYourLastName.java and your WidgetOrderYourLastNameTest.java to the assignment below. Make sure you have both of the files attached.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started