This page lists the milestone requirements for Milestone 2 of the CC 410 Restaurant Project. Read the requirements carefully and discuss any questions with the instructors or TAs.
The CC 410 Restaurant Project project for this semester is centered around building a point of sale (POS) system for a fictional restaurant named Starfleet Subs, based in the Star Trek universe.
The second milestone involves writing documentation and unit tests for our existing code base. Our goal is to adequately test each part of our code via unit tests, reaching 100% code coverage at a minimum. In addition, we’ll add all of the required documentation comments in our existing code.
Warning
The first couple of milestones only require a subset of the general requirements introduced in the “Hello Real World” project. Read this section carefully to see what is required for this particular milestone.
This milestone must follow these professional coding standards:
__init__.py
and __main__.py
are exempt.application
plugin. The project should compile without errors. You may include a main class in a separate package for testing purposes only.The following requirements ARE NOT enforced for this milestone, but will be enforced in later milestones that use the same code. We will focus on learning to meet each of these requirements in future modules. However, you are welcome to “plan ahead” by minimizing the number of style errors in your code and adding some basic documentation where desired.
Tip
You can make things easier on yourself by following proper naming standards for your language of choice, even though we aren’t enforcing a style guide for this milestone.
ClassName
, methods and attributes start with lowercase like methodName
. See the Google Style Guide.method_name
, with the exception of classes, which are named in CamelCase starting with an uppercase letter like ClassName
. See the Google Style Guide.It is easier to get this correct from the start, then having to refactor your code later. Of course, major refactoring is also a good lesson that guarantees you’ll get it right in the future!
flake8-docstrings
and pep8-naming
plugins. Code should conform to PEP 8 style with Google style docstrings.This milestone should include the following features:
test
directory for the class it is testing.src
directory.java
or python
folder).Tip
Some quick tips from when I did this milestone:
PRICE = 0.50
attribute, and then use that value in your unit test. In that way, when you copy and paste unit test code, you can simply change the global attributes to match the item being tested. Many tests can be generalized in that way such that all entrée test classes share the same code for many tests, referring to global attributes that are changed in each class. The same works for drinks and sides.ham
or lemon
) can be done using reflection or metaprogramming, but I don’t recommend it. Since each ingredient is an individual attribute, generalization is very complex and prone to errors. Those tests were hard-coded for each individual ingredient in my solution.@pytest.mark.parametrize("bread", Bread)
.default
branches in switch statements across enums, which will be unreached in code coverage. This is fine, but a good reason to avoid switch statements, as you will never get 100% code coverage! I ended up changing my model solution to remove switch statements.-Russ
Completing this project is estimated to require 3-8 hours.
Tip
In my testing, this milestone requires around 3500-4000 lines of code (including very rudimentary documentation comments) in the unit tests directory. As with the prior milestone, much of the code can be carefully copy-pasted between files with similar attributes. My best suggestion is to pick one of the complex entrées like TheRiker
and start there writing unit tests. Once you have the entrées all working, the sides and drinks are pretty easy and use much of the same structure. There are 423 unit tests in my model solution. I ended up finding half a dozen errors in my model solution for milestone 1, showing the importance of unit testing! -Russ
This assignment will be graded based on the rubric below:
The following deductions apply:
This is not an exhaustive list of possible deductions. The instructors will strive to provide reasonable and fair grading, but we can’t predict all possible defects. It is up to the student to ensure that the project is complete and correct before submission.
Submit this assignment by creating a release on GitHub and uploading the release URL to the assignment on Canvas. You should not submit this Codio project or mark it as complete in Codio, in case you need to come back to it and make changes later.
Each entrée test class should contain unit tests for the following:
SpecialInstructionsInitiallyEmpty()
- the SpecialInstructions
list should be empty when the object is createdHasCorrectBreadInitially()
- the Bread
attribute is initially set correctlyHasCorrectPrice()
- the price
is correctHasCorrectCalories()
- the calories
is correctNameIsCorrectForBread(Bread)
- call the toString()
or __str__()
method with each type of bread and verify the output.IncludesCorrectCondimentsByDefault(Condiment)
- for each condiment, check if it is included or not by default.
boolean
value indicating if the condiment should be included by default.AddRemoveCondiments(Condiment)
- for each condiment, check that it can be added and removed, and the Condiments
set will change accordingly.Has<Ingredient>ByDefault()
- for each ingredient, check to see that it is included by default (returns true).
TheKirk
would have a test method HasHamByDefault()
.Change<Ingredient>SetsSpecialInstructions()
- for each ingredient, check that changing it from and to the default value will add and remove the correct item from the SpecialInstructions
list.
TheKirk
would have ChangeHamSetsSpecialInstructions()
that would confirm setting ham
to false
would add "Hold Ham"
to the list of SpecialInstructions
.ChangeMultipleIngredientSpecialInstructions()
- confirm that changing multiple ingredients from their default values will add multiple items to the SpecialInstructions
list.
SameObjectsAreEqual()
- generate two different instances of the item, and confirm that they are equal using equals()
(Java) or ==
(Python).DifferentBreadNotEqual()
- generate two different instances of the item using different bread, and confirm that they are not equal using equals()
(Java) or ==
(Python).DifferentIngredientsNotEqual()
- generate two different instances of the item using different sets of ingredients, and confirm that they are not equal using equals()
(Java) or ==
(Python).DifferentCondimentsNotEqual()
- generate two different instances of the item using different sets of condiments, and confirm that they are not equal using equals()
(Java) or ==
(Python).WrongObjectNotEqual()
- generate an instance of the item and an instance of a different menu item, and confirm that they are not equal using equals()
(Java) or --
(Python). This should not throw an exception.Each side test class should contain unit tests for the following:
DefaultSizeCorrect()
- each side should have the default size of Small
when initially created.HasCorrectNameForSize(Size)
- call the toString()
or __str__()
method with each size and verify the output.HasCorrectPriceForSize(Size)
- the price
is correct for each sizeHasCorrectCaloriesForSize(Size)
- the calories
is correct for each sizeSameObjectsAreEqual()
- generate two different instances of the item, and confirm that they are equal using equals()
(Java) or ==
(Python).DifferentSizeNotEqual()
- generate two different instances of the item using different sizes, and confirm that they are not equal using equals()
(Java) or ==
(Python).WrongObjectNotEqual()
- generate an instance of the item and an instance of a different menu item, and confirm that they are not equal using equals()
(Java) or --
(Python). This should not throw an exception.Each drink test class should contain unit tests for the following:
SpecialInstructionsInitiallyEmpty()
- the SpecialInstructions
list should be empty when the object is createdDefaultSizeCorrect()
- each drink should have the default size of Small
when initially created.HasCorrectNameForSize(Size)
- call the toString()
or __str__()
method with each size and verify the output.HasCorrectPriceForSize(Size)
- the price
is correct for each sizeHasCorrectCaloriesForSize(Size)
- the calories
is correct for each sizeHas<Ingredient>ByDefault()
- for each ingredient included by default, check to see that it is included (returns true). For example, ThePicard
would have a test method HasLemonByDefault()
.DoesNotHave<Ingredient>ByDefault()
- for each optional ingredient not included by default, check to see that it is not included (returns false).
ThePicard
would have a test method DoesNotHaveIceByDefault()
.Change<Ingredient>SetsSpecialInstructions()
- for each ingredient, check that changing it from and to the default value will add and remove the correct item from the SpecialInstructions
list.
ThePicard
would have ChangeIceSetsSpecialInstructions()
that would confirm setting ice
to true
would add "Add Ice"
to the list of SpecialInstructions
.ChangeMultipleIngredientSpecialInstructions()
- confirm that changing multiple ingredients from their default values will add multiple items to the SpecialInstructions
list.
SameObjectsAreEqual()
- generate two different instances of the item, and confirm that they are equal using equals()
(Java) or ==
(Python).DifferentSizeNotEqual()
- generate two different instances of the item using different sizes, and confirm that they are not equal using equals()
(Java) or ==
(Python).DifferentIngredientsNotEqual()
- generate two different instances of the item using different sets of ingredients, and confirm that they are not equal using equals()
(Java) or ==
(Python).WrongObjectNotEqual()
- generate an instance of the item and an instance of a different menu item, and confirm that they are not equal using equals()
(Java) or --
(Python). This should not throw an exception.Tip
Extra Credit: After writing all of the unit tests listed above, feel free to suggest any unit tests you feel are missing. Email your added tests to the course help email address and you may earn bug bounty points for your suggestions!