O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting ready

At the time of this writing, the latest stable version of JUnit is 4.12, which can be used by adding the following Maven dependency to the pom.xml project level:

<dependency>  <groupId>junit</groupId>  <artifactId>junit</artifactId>  <version>4.12</version>  <scope>test</scope></dependency>

After this, you can write your first JUnit test. Let's assume you have the Vehicle class created in the src/main/java/com/packt/cookbook.ch02_oop.a_classes folder (this is exactly the code we discussed in Chapter 2Fast Track to OOP - Classes and Interfaces, of this book):

package com.packt.cookbook.ch02_oop.a_classes;public class Vehicle {  private int weightPounds;  private Engine engine;  public Vehicle(int weightPounds, Engine engine) {    this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required