Behavior Driven Development with JUnit 5. Part 5

  • The Cucumber plugin generates a method annotated with @Given(“^there is an economy flight$”), meaning this method is executed when the step Given there is an economy flight from the scenario is executed #1.
  • The plugin generates a method stub to be implemented with the code addressing the step Given there is an economy flight from the scenario #2.
  • The plugin generates a method annotated with @When(“^we have a regular passenger$”), meaning this method is executed when the step When we have a regular passenger from the scenario is executed #3.
  • The plugin generates a method stub to be implemented with the code addressing the step When we have a regular passenger from the scenario #4.
  • The plugin generates a method annotated with @Then(“^you can add and remove him from an economy flight$”), meaning this method is executed when the step. Then you can add and remove him from an economy flight from the scenario is executed #5.
  • The plugin generates a method stub to be implemented with the code addressing the step Then you can add and remove him from an economy flight from the scenario #6.
  • The rest of the methods are implemented in a similar way; we have covered the Given, When, and Then steps of one scenario.
  • We declare the instance variables for the test, including economyFlight and mike as a Passenger #1.
  • We write the method corresponding to the Given there is an economy flight business logic step #2 by initializing economyFlight #3.
  • We write the method corresponding to the When we have a regular passenger business logic step #4 by initializing the regular passenger mike #5.
  • We write the method corresponding to the Then you can add and remove him from an economy flight business logic step #6 by checking all the conditions using the assertAll JUnit 5 method, which can now be read fluently #7.
  • The rest of the methods are implemented in a similar way; we have covered the Given, When, and Then steps of one scenario.

https://www.luxoft-training.com/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Design and Code

What happens when you type ls -l in the shell ?

Sound Check: Putting Sounds In Your Game

CS373 Spring 2022: William Johnston

AWS CSA-A Exam — Nervous Final Reading

Back to the Basics: Recursion

It Takes a Village to Raise a System

Consider the entire “community” involved with delivering a system!

Boss Fight: Arming the front guns

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Luxoft Training

Luxoft Training

https://www.luxoft-training.com/

More from Medium

Good practise to use Equals and Hashcode Method in Hibernate

git version at runtime and packaging

Spring Cloud Config Server Encryption and Decryption using Git Repository

Why Java is platform independent