This repository contains Java classes for managing a list of passengers, part of a larger project to demonstrate Java programming and unit testing techniques.
The primary task of this project assignment is to provide a simple demonstration of handling objects within Java, specifically focusing on passenger management especially best practices in writing clean, testable code and implementing unit tests using JUnit.
- Java: The main programming language used for the development of the passenger management system.
- JUnit: Utilized for unit testing to ensure the reliability and accuracy of the code.
Passenger.java: Defines thePassengerclass with attributes such as name, ID, phone, etc., and includes methods to handle these attributes.PassengerList.java: Manages a list ofPassengerobjects and includes methods to add and find passengers in the list.PassengerTest.java: Contains unit tests for thePassengerclass to verify the functionality of its methods.PassengerListTest.java: Tests the methods of thePassengerListclass, ensuring the list management works as expected.
To run the unit tests for this project, you'll need Java and JUnit set up on your machine. Follow these steps:
- Clone this repository.
- Ensure that you have Java and JUnit installed on your system.
- Navigate to the project directory.
- Compile the classes, including the test classes. Use the following command if using a simple Java setup:
javac -cp .;path_to_junit.jar *.java
Run the tests using Java. You can do this by running:
Replace path_to_junit.jar with the actual path to your JUnit jar file.
java -cp .;path_to_junit.jar org.junit.runner.JUnitCore ie.gmit.PassengerTest ie.gmit.PassengerListTest Replace path_to_junit.jar with the actual path to your JUnit jar file. This setup will execute all the tests defined in the test classes, outputting the results directly to your console.