Let's talk about naming conventions just for a second here.
We got the test method books, flights.
Well, a test methods name should clearly reveal the scenario.
It should explicitly state the behavior it expects.
And there are some naming conventions for test method naming.
But my preferred approach is not to stick too much to the test naming conventions.
I would rather focus on the clarity of the method names.
However, one of the test method naming conventions I want to show here is the g w t pattern based on
the g w t pattern that books flights method here should be named differently.
Let me rename it.
It should be named J for given given a flight w for when When I book the flight t for then.
Then the flight should contain my booking.
You will see that just in a second.
There we go.
Okay, so here we got the test method name based on g w t given a flight.
When I book the flight, then the flight should contain my booking.
I mean, it totally makes sense, right?
And you got all the given when and then steps included in one name.
But it's long as hell.
I mean, it's really like not easy to read and it's really too long.
So we need to be creative and find the clearest yet shortest sentence that explicitly describes the
behavior of the system under test.
And in this scenario, the system under test for sure is the booking service.
So let's rename that again and give it a name, which is fine.
So books flights was the initial name, but a better name would be for example, remembers bookings.
So this is exactly what happens inside of our test.
Thus our system under test.
Remember it's bookings, right?
So this is why we call it remembers bookings.
And we can do exactly the same thing here for cancel bookings.
We're not really checking for cancellation.
We are checking for well, do we have the seats freed up after cancellation?
So we should rename it instead of cancel booking?
We call it frees up seats after booking because that's what we want to test, right?
So after we booked something and cancel that, do we have seats again?
Free?
Okay.
I just wanted to show you that and talk a little bit about that naming convention.
However, just be creative and find the clearest and shortest sentence that exactly describes the behavior
of your testing method here.