Question

Write the test cases for booking flights in a airline reservation management system. What testing method...

Write the test cases for booking flights in a airline reservation management system. What testing method can be used?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

UNIT TESTING

The Unit Testing is a test that tests each single module of the software to check for errors. This is mainly done to discover errors in the code of the Airline Reservation System. The main goal of the unit testing would be to isolate each part of the program and to check the correctness of the code. In the case of the Airline Reservation System, all the web forms and the Java classes will be tested.

There are many benefits for this unit testing:

  • The unit testing facilitates change in the code.
  • It allows testing to be done in a bottom up fashion.

At the same time, unit testing has some disadvantages such as, it might not identify each and every error in the system.

I have created very basic Flight reservation system in Java.

-------------------------------------------Flight.java---------------------------------------------

public class Flight {
    String flightName;
    String flightFrom;
    String flightTo;
    int flightCost;

    public Flight(String flightName, String flightFrom, String flightTo, int flightCost){
        this.flightName = flightName;
        this.flightFrom = flightFrom;
        this.flightTo = flightTo;
        this.flightCost = flightCost;
    }

    public String getFlightName() {
        return flightName;
    }

    public String getFlightFrom() {
        return flightFrom;
    }

    public String getFlightTo() {
        return flightTo;
    }

    public int getFlightCost() {
        return flightCost;
    }

    @Override
    public String toString() {
        return "Flight{" +
                "flightName='" + flightName + '\'' +
                ", flightFrom='" + flightFrom + '\'' +
                ", flightTo='" + flightTo + '\'' +
                ", flightCost=" + flightCost +
                '}';
    }
}

This class will hold the flight details like flight name , flight from , flight to and flight cost.

By using Flights class constructor we will set all the flight details.

-----------------------------------------------------User.java---------------------------------

public class User {
    String userName;
    long contactNumber;

    User(String userName, long contactNumber){
        this.userName = userName;
        this.contactNumber = contactNumber;
    }

    public String getUserName() {
        return userName;
    }

    public long getContactNumber() {
        return contactNumber;
    }
}

This User class will hold the user details like user name and their contact numbers.

-----------------------------------------------Trip.java-------------------------------------

import java.util.List;

public class Trip {
    Flight flight;
    List<User> user;

    public Flight getFlight() {
        return flight;
    }

    public void setFlight(Flight flight) {
        this.flight = flight;
    }

    public List<User> getUser() {
        return user;
    }

    public void setUser(List<User> users) {
        this.user = users;
    }

    public void showTripDetails(){
        System.out.println(this.flight.toString());
        System.out.println("Passengers travelling in this flight.");
        for(User user: this.user){
            System.out.println(user.userName);
        }
        System.out.println();
    }
}

Trip class will hold the data of flight details and the passenger travelling in this flight.

----------------------------------------------------BookFlight.java-----------I-------------------------

import java.util.ArrayList;
import java.util.List;

public class BookFlight {
    public static void main(String args[]){
        Flight flight1 = new Flight("Boeing", "New York", "Dubai", 800);
        Flight flight2 = new Flight("JetBlue", "New York", "Denver", 600);

        User user1 = new User("Sophia", 67655556);
        User user2 = new User("William", 98767565);
        User user3 = new User("Jayden", 67687556);

        Trip trip1 = new Trip();
        trip1.setFlight(flight1);
        List<User> userList1 = new ArrayList<>();
        userList1.add(user1);
        userList1.add(user2);
        trip1.setUser(userList1);

        trip1.showTripDetails();

        Trip trip2 = new Trip();
        trip2.setFlight(flight2);
        List<User> userList2 = new ArrayList<>();
        userList2.add(user3);
        trip2.setUser(userList2);

        trip2.showTripDetails();

    }
}

BookFlight contains the main method, this is demo of this app. If you run this you can see how flights are created, user creation and how users are added to the flights. And we can see the trip details.

-------------------------------------------------------UnitTestCases.java--------------------------

import org.junit.Test;
import static org.junit.Assert.*;

public class UnitTestCases {
    @Test
    public void testFlightConstructor(){
        Flight flight1 = new Flight("Boeing", "New York", "Dubai", 800);
        assertEquals("Boeing",flight1.getFlightName());
        assertEquals("New York",flight1.getFlightFrom());
        assertEquals("Dubai",flight1.getFlightTo());
        assertEquals(800,flight1.getFlightCost());
    }

    @Test
    public void testUserConstructor(){
        User user1 = new User("Sophia", 67655556);
        assertEquals("Sophia",user1.getUserName());
        assertEquals(67655556,user1.getContactNumber());
    }
}

I created some easy test cases using Junit to test the constructors of Flight and User Class to check whether all the data is set properly.

You can add more test cases if you want to. It all depends on the developer that how much effort they put to create the test cases. To avoid all the bugs in their app.

------------------------------------------Output of BookFlight----------------------------

Add a comment
Know the answer?
Add Answer to:
Write the test cases for booking flights in a airline reservation management system. What testing method...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Create a class called Plane, to implement the functionality of the Airline Reservation System. Write...

    C++ Create a class called Plane, to implement the functionality of the Airline Reservation System. Write an application that uses the Plane class and test its functionality. Write a method called CheckIn() as part of the Plane class to handle the check in process Prompts the user to enter 1 to select First Class Seat (Choice: 1) Prompts the user to enter 2 to select Economy Seat (Choice: 2) Assume there are only 5-seats for each First Class and Economy...

  • Imagine that you created the diagram below representing an airline reservation system. You now need to...

    Imagine that you created the diagram below representing an airline reservation system. You now need to add detail to the use cases shown below. For two of the use cases below, create a separate use case diagram that adds the next level of detail. Reservation System Initial Design: Check in Passenger Ticket Clerk Add Reservation Cancel Reservation Create your Use Case Diagram in your favorite application, save it to a file (pdf, docx or jpg), and then upload it.

  • A test specification provides designers with what needs to be known in order to perform a...

    A test specification provides designers with what needs to be known in order to perform a specific test, and to validate and verify the requirement to be tested. The test script is divided into the test script, which is the generic condition to be tested, and one or more test cases within the test script. Provide a test script and test case for at least 3 of your requirements identified in your requirements specification. Provide the following format for an...

  • & 8.3.37 Question Help A major airline recently began encouraging reservation agents to nap durin...

    & 8.3.37 Question Help A major airline recently began encouraging reservation agents to nap during their breaks. The table to the right lists the number of complaints received about each of a sample of 8 reservation agents during the 6 months before naps were encouraged and during the 6 months after the policy change a. Do the data present sufficient evidence to conclude that the new napping policy reduced the mean number of customer complaints? Test using a 0.01 b....

  • Programming Language: C++ Develop a seat reservation system for your airline. Consider the following airline seating...

    Programming Language: C++ Develop a seat reservation system for your airline. Consider the following airline seating pattern: A         1          2          3          4          5          6          7          8          9          ……    100 B         1          2          3          4          5          6          7          8          9          ……    100 AISLE C         1          2          3          4          5          6          7          8          9          ……    100 D         1          2          3          4          5          6          7          8          9          ……    100 Either use 2D STL array (array that contains array) or 4 single dimensional STL arrays of size 100. Write a program to display a menu to the user with the options to reserve a seat of choice, reserve a window seat, reserve an aile seat, reserve a seat (any available), withdraw reservation, update reservation (change seat) and display...

  • hi I need some help with creating umls for use-case driven diagram for a airline reservation...

    hi I need some help with creating umls for use-case driven diagram for a airline reservation system a architecture-centric for functional, structural, and behavior diagram that shows the three basic processes and properties of each diagram for the airline reservation system and the iterative-incremental diagram. Also I need to explain each diagram from these critical elements. In their 1999 book The Unified Software Development Process, the authors of Unified Modeling Language (UML) noted that any modern object-oriented approach to developing...

  • For hotel management system that facilitate search, booking, and payment processes for all of the...

    for hotel management system that facilitate search, booking, and payment processes for all of the administrator and customers answer the following : 1- Based on the type, size and the needs of your system, and after conducting a thorough research, conclude what type of database would you suggest creating for your system? Justify your answer in detail and explain why other types are not suitable. 2- Create a story board for your use case showing the dialog sequence in the...

  • A national air traffic control system handled an average of 47,915 flights during 28 randomly selected...

    A national air traffic control system handled an average of 47,915 flights during 28 randomly selected days in a recent year. The standard deviation for this sample is 6,402 flights per day. Complete parts a through c below. a. Construct a 99​% confidence interval to estimate the average number of flights per day handled by the system. The 99​% confidence interval to estimate the average number of flights per day handled by the system is from a lower limit of...

  • JAVA Notes on Testing • Unit Testing - creates a test case for each module of...

    JAVA Notes on Testing • Unit Testing - creates a test case for each module of code that been authored. The goal is to ensure correctness of individual methods • Integration Testing - modules that were individually tested are now tested as a collection. This form of testing looks at the larger picture and determines if bugs are present when modules are brought together • System Testing - seeks to test the entire software system and how it adheres to...

  • Explain why each is right or wrong Documentation and testing Unit testing should only test common...

    Explain why each is right or wrong Documentation and testing Unit testing should only test common input cases Unit testing is a type of verification The main method of a class should perform extensive unit testing of the class unless it is the class driving the execution of a program All programs/classes should have a README file which clearly describes what the program/class does, how it is implemented, how it is used, whom wrote the code and bug fixes All...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT