Code Monkey home page Code Monkey logo

cucumber-tests's Introduction

Book Extra Chapters | E.1. Cucumber Tests

This repository includes the source code for an extra chapter of the book Learn Microservices with Spring Boot.

The full contents of this extra chapter are available online: End-To-End Tests with Cucumber.

In this online tutorial, I show you how to set up a Cucumber project with cucumber-jvm, the Java module. Then, you'll learn a few core aspects:

  • An overview of Cucumber and the Gherkin syntax.
  • How to map steps to Java code with Cucumber Step definitions.
  • Divide features and step definitions.
  • Use different placeholders for step method's arguments.
  • Connect from Cucumber to a backend server via REST API.
  • DataTable examples
  • etc.

Running the code

Requirements:

  • Docker (including Docker Compose)
  • JDK (14+)

To run the cucumber tests against the backend server, you need to deploy the backend services first ๐Ÿ™‚

The backend has two Spring Boot microservices with business logic, a gateway, a discovery server, the RabbitMQ broker, and a centralized logs service. You can run the complete system using Docker Compose. If you're interested in how to build this system from scratch, and analyze the pros/cons of microservices, check out my book.

For our tests, we access the system using the same entry points as the frontend: the REST API exposed via Gateway on localhost:8000/.

Getting the backend up and running is simple. You can pull the publicly available images using Docker Compose. First, clone the code of the book's last chapter:

$ git clone https://github.com/Book-Microservices-v2/chapter08d.git

Then, navigate to the docker folder inside the repo, and run the Compose version that points to the public images:

$ cd chapter08d/docker
$ docker-compose -f docker-compose-public.yml up

After the complete system is up and running (it may take some time), you can run the cucumber tests in this repository with the Maven Wrapper.

# In Linux/Mac
$ ./mvnw clean test

# In windows
> mvnw.cmd clean test

You should see the test results in console. If you're curious about what's happening in the backend, just have a look at the docker logs. Events are propagated, and the Gamification microservice assigns new score and badges.

Remember that the full contents of the guide are available online, for free.

Did you like the tutorial? Great! Please star this repo ๐Ÿ˜„ Thanks!

cucumber-tests's People

Contributors

mechero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.