-
Notifications
You must be signed in to change notification settings - Fork 0
LuggageManifestTest Documentation
The LuggageManifestTest class is a test class for the LuggageManifest class, using the JUnit frameworks for testing.
- The LuggageManifestTest class is called via the Test Suite Class Test Suite and therefore requires no individual instance for the required functionality. The below code showcases how the LuggageManifestTest class is referenced and utilized:
@RunWith(Suite.class)
@Suite.SuiteClasses({
LuggageManagementSystemTest.class,
PassengerTest.class,
LuggageSlipTest.class,
LuggageManifestTest.class,
FlightTest.class
})
-
This class is used with the Template design pattern as a subclass of the TestTemplate class.
-
The main methods implemented are as follows:
-
testSlips() -
testCreateLuggageManifest() -
testAddLuggage() -
testGetExcessLuggageCost() -
testGetExcessLuggageCostByPassenger() -
testToString()
-
These methods are used to test method & attribute naming conventions and types, behaviour and functionality of methods, expected abstractions and inheritance hierarchies of the student's submitted LuggageManifest.java file.
Methods
The below methods are used to test the naming conventions and functionality of the student's submitted LuggageManifest class. For each method there is no returned object nor any accepted parameters, however, the use of inherited attributes from the parent class, TestTemplate is used to track its grading, i.e.
- boolean passed is used to indicate whether a particular test condition is true and therefore the designated mark should be awarded.
- Class<?> testClass is used to set the class type to LuggageManifest to indicate the LuggageManifest class is being tested.
Note: The inherited attribute int passedTestMarks is decremented for each test that fails, thereby determining the mark to be awarded for the "Passes JUnit Tests" section.
A Feedback object is created at the end of each test, reflecting the appropriate feedback response and mark to be displayed from the test result.
-
@Before public void init(): This method reinitializes the requisite variables before each test annotated with@Test
mark = 0;
response = "";
declaredOnly = false;
passed = false;
field = null;
testClass = LuggageManifest.class;
luggageManifest1 = new LuggageManifest();
-
@Test public void testSlips(): This method is used to test the use of proper naming convention and type (ArrayList) of theslipsfield in the student LuggageManifest class.
-
@Test public void testCreateLuggageManifest(): Asserts that theArrayList<LuggageSlip> slipsis accurately initialized within the LuggageManifest constructor.
-
@Test public void testAddLuggage(): Asserts that the number of luggage possessed by the passenger is created and added to the slips attribute. The excess cost should also be accurately calculated and added to thelabelattribute of the LuggageSlip object. An accurate String representation of the passenger object, number of LuggageSlips created and added along with the excess cost accrued should be outputted.
-
@Test public void testGetExcessLuggageCost(): Asserts that an accurate calculation is made for the excess luggage cost, i.e. where the number of luggage a passenger has exceeds the number of allowed luggage by cabin class. This is calculated by number of excess luggage * 35.00.
-
@Test public void testGetExcessLuggageCostByPassenger(): Asserts that an accurate String representation is returned, for a given passenger passport number, of the total cost of excess luggage on the flight's manifest.
-
@Test public void testToString(): Asserts that the returned String accurately represents the LuggageManifest object, i.e an aggregated representation of each LuggageSlip object in the slips attribute.
Fields
-
private LuggageManifest luggageManifest1: An initialized LuggageManifest attribute used to test the accuracy of the LuggageManifest class functionality.