11 Running JUnit tests from Gradle 6

 

This chapter covers

  • Introducing Gradle
  • Setting up a Gradle project
  • Using Gradle plugins
  • Creating a Gradle project from scratch and testing it with JUnit 5
  • Comparing Gradle and Maven

Mixing one’s wines may be a mistake, but old and new wisdom mix admirably.

--Bertolt Brecht

In this chapter, we will analyze the last part of the world of build system tools. Gradle is an open source build-automation system that started with the concepts of Apache Ant and Apache Maven. Instead of the XML form that Apache Maven uses, as you saw in chapter 10, Gradle introduces a domain-specific language (DSL) based on Groovy for declaring the project configuration.

A DSL is a computer language dedicated to addressing a specific application domain. The idea is to have languages whose purpose is to solve problems belonging to a specific domain. In the case of builds, one of the results of applying the DSL idea is Gradle. Groovy is a Java-syntax-compatible object-oriented programming language that runs on the Java Virtual Machine (JVM).

11.1 Introducing Gradle

We'll take a look at various aspects of using Gradle to manage building and testing Java applications, with a focus on testing. We have worked with Maven, and you know from chapter 10 that it uses convention over configuration. Gradle also has a series of building conventions that we can follow when we do the build. This allows other developers who are also using Gradle to easily follow our build’s configuration.

11.2 Setting up a Gradle project

11.3 Using Gradle plugins

11.4 Creating a Gradle project from scratch and testing it with JUnit 5

11.5 Comparing Gradle and Maven

Summary