Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how can i add fhe zip file Task 4 - On Your Own - A Vending Machine. You should now be prepared to test some

image text in transcribed
image text in transcribed
how can i add fhe zip
file
Task 4 - On Your Own - A Vending Machine. You should now be prepared to test some relatively simply source code on your own. For this task, you will develop tests for code that implements a simple vending machine Download the Vending Machine.zip Eclipse project from Blackboard (Projects Project 2) and import it to your Eclipse workspace. Examine the source code and generated JavaDocs. Note that this is simply an implementation of a vending machine, since it has no main method. you cannot actually execute it, as is. Since this is a simple vending machine, there are only four slots with codes A, B, C, and to identify them. Each slot only holds one item. A slot may be empty. To buy yummies from this machine, you put money into it and select the item you want using the code for the slot(e.g. the code "A" selects the item from the first slot). You will be writing a test suite that tests the functionality of this simple vending machine You should write unit tests for the following classes and functions: Vending Machine tem VendingMachineltem Constructor String getName String getPrice - Vending Machine void additem(VendingMachineltem item, String code) Vending Machineltem removeitem/String code) void insertMoney(devuble amount) double getBalance boolean make Purchase) double returnChangel You do not need to test other parts of the Vending Machine class, such as the constructor For cach class, create a JUnit test case and name it (class nameTest.java. For example. Vending Machine.java will have a JUnit test case called Vending Machine Testjava. Inside your JUnit test case, you will have a series of test functions. Try to make each test fiction test only one aspect of a particular function. For example, if you would like to test if a function, named foobart) works correctly on normal inputs. put your test for normal inputs in a separate function from a test that checks if it throws an exception with weird inputs. This way, if Unit reports that a test has not passed, you know exactly which aspect of your code made the test fail. Make sure you comment your testing code. In the test method comments, make sure that you add a brief sentence to describe exactly what you are testing in that test method. Once you've completed the unit tests, you need a test suite called AllTests java which runs all the unit tests as a test suite. This is easily done via right clicking on your project selecting New Other Java Unit Unit Test Suite Warning! This may sound casy but it will require quite a bit of code. As you should have seen thus far, designing tests takes significant thought and the mentality that you have to break the code". A few suggestions you may want to consider: Read the comments in the JavaDoc describing each function (ie, start in index.html). -Pay close attention to what each function is supposed to do, as described in the comments. Think of ways to use the public functions to verify that the function does what it is supposed to -Pay close attention to why exceptions are thrown. - Pay close attention to pre-conditions and post-conditions. Romsmbsr to test 99 example, if you would like to test if a function, named foobar() works correctly on normal inputs, put your test for normal inputs in a separate function from a test that checks if it throws an exception with weird inputs. This way, if JUnit reports that a test has not passed, you know exactly which aspect of your code made the test fail. Make sure you comment your testing code. In the test method comments, make sure that you add a brief sentence to describe exactly what you are testing in that test method. Once you've completed the unit tests, you need a test suite called AllTests.java which runs all the unit tests as a test suite. This is easily done via right clicking on your project selecting New Other Java JUnit JUnit Test Suite. Warning! This may sound easy but it will require quite a bit of code. As you should have seen thus far, designing tests takes significant thought and the mentality that you have to break the code". A few suggestions you may want to consider: . Read the comments in the JavaDoc describing each function (i.e., start in index.html). Pay close attention to what each function is supposed to do, as described in the comments. Think of ways to use the public functions to verify that the function does what it is supposed to. Pay close attention to why exceptions are thrown. Pay close attention to pre-conditions and post-conditions. . Remember to test "good" inputs and "bad" inputs. Remember to test both sides of a boundary condition. For example, if I have a function that takes an argument x and returns true if x is >= 5, remember to write tests for x = 5. Finally, there are several potential faults in the code. The goal of testing is to find these bugs. For every bug that you find within the code, correct the bug in the code and describe it in a bugs.txt file that you create in the root directory of the project directory. Hint: The better the testing you do on the Vending Machine code in this project, the easier subsequent projects will be. Once you have completed this task, you should commit this project to your repository (with appropriate commit comments!). Task 4 - On Your Own - A Vending Machine. You should now be prepared to test some relatively simply source code on your own. For this task, you will develop tests for code that implements a simple vending machine Download the Vending Machine.zip Eclipse project from Blackboard (Projects Project 2) and import it to your Eclipse workspace. Examine the source code and generated JavaDocs. Note that this is simply an implementation of a vending machine, since it has no main method. you cannot actually execute it, as is. Since this is a simple vending machine, there are only four slots with codes A, B, C, and to identify them. Each slot only holds one item. A slot may be empty. To buy yummies from this machine, you put money into it and select the item you want using the code for the slot(e.g. the code "A" selects the item from the first slot). You will be writing a test suite that tests the functionality of this simple vending machine You should write unit tests for the following classes and functions: Vending Machine tem VendingMachineltem Constructor String getName String getPrice - Vending Machine void additem(VendingMachineltem item, String code) Vending Machineltem removeitem/String code) void insertMoney(devuble amount) double getBalance boolean make Purchase) double returnChangel You do not need to test other parts of the Vending Machine class, such as the constructor For cach class, create a JUnit test case and name it (class nameTest.java. For example. Vending Machine.java will have a JUnit test case called Vending Machine Testjava. Inside your JUnit test case, you will have a series of test functions. Try to make each test fiction test only one aspect of a particular function. For example, if you would like to test if a function, named foobart) works correctly on normal inputs. put your test for normal inputs in a separate function from a test that checks if it throws an exception with weird inputs. This way, if Unit reports that a test has not passed, you know exactly which aspect of your code made the test fail. Make sure you comment your testing code. In the test method comments, make sure that you add a brief sentence to describe exactly what you are testing in that test method. Once you've completed the unit tests, you need a test suite called AllTests java which runs all the unit tests as a test suite. This is easily done via right clicking on your project selecting New Other Java Unit Unit Test Suite Warning! This may sound casy but it will require quite a bit of code. As you should have seen thus far, designing tests takes significant thought and the mentality that you have to break the code". A few suggestions you may want to consider: Read the comments in the JavaDoc describing each function (ie, start in index.html). -Pay close attention to what each function is supposed to do, as described in the comments. Think of ways to use the public functions to verify that the function does what it is supposed to -Pay close attention to why exceptions are thrown. - Pay close attention to pre-conditions and post-conditions. Romsmbsr to test 99 example, if you would like to test if a function, named foobar() works correctly on normal inputs, put your test for normal inputs in a separate function from a test that checks if it throws an exception with weird inputs. This way, if JUnit reports that a test has not passed, you know exactly which aspect of your code made the test fail. Make sure you comment your testing code. In the test method comments, make sure that you add a brief sentence to describe exactly what you are testing in that test method. Once you've completed the unit tests, you need a test suite called AllTests.java which runs all the unit tests as a test suite. This is easily done via right clicking on your project selecting New Other Java JUnit JUnit Test Suite. Warning! This may sound easy but it will require quite a bit of code. As you should have seen thus far, designing tests takes significant thought and the mentality that you have to break the code". A few suggestions you may want to consider: . Read the comments in the JavaDoc describing each function (i.e., start in index.html). Pay close attention to what each function is supposed to do, as described in the comments. Think of ways to use the public functions to verify that the function does what it is supposed to. Pay close attention to why exceptions are thrown. Pay close attention to pre-conditions and post-conditions. . Remember to test "good" inputs and "bad" inputs. Remember to test both sides of a boundary condition. For example, if I have a function that takes an argument x and returns true if x is >= 5, remember to write tests for x = 5. Finally, there are several potential faults in the code. The goal of testing is to find these bugs. For every bug that you find within the code, correct the bug in the code and describe it in a bugs.txt file that you create in the root directory of the project directory. Hint: The better the testing you do on the Vending Machine code in this project, the easier subsequent projects will be. Once you have completed this task, you should commit this project to your repository (with appropriate commit comments!)

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

Development Of Knowledge Framework For Affective Content Analysis

Authors: Swarnangini Sinha

1st Edition

B0CQJ13WZ1, 979-8223977490

More Books

Students also viewed these Databases questions

Question

What are the key elements in the AFG Planning Cycle?

Answered: 1 week ago

Question

D How will your group react to this revelation?

Answered: 1 week ago