JUnit Tests

How you quickly can get up and runnin writing unit tests in JUnit

Unit testing is nowadays a pre-requisite to maintain high coding quality. In this course you will learn about the JUnit library, hamcrest matchers, how to apply mock objects and much more during this fully loaded course day.

This course appeal to Java developers that are starting as a member of a Java project and need to quickly be productive in writing unit tests.

This is what you will learn
  • The principles behind unit testing
  • The principles behind test-driven development (TDD)
  • The JUnit library
  • Test annotations
  • Assertions and matchers
  • The principles for mock objects and usage of Mockito
  • JUnit together with build tools as Maven and Gradle
  • Overview of other testing frameworks
Course Contents

Unit Testing and Test-Driven Development

  • Background of JUnit
  • What is a unit test
  • What is an integration test
  • What other form of tests are there
  • What is TDD (Test-Driven Development)
  • Installation of JUnit

Basic JUnit Usage

  • Test methods
  • Test method annotations
  • Using test assertions
  • Running inside IntelliJ (or your favorite IDE)
  • Compiling and running tests from the command-line

Life-Cycle Methods

  • Before / After annotations
  • BeforeClass / AfterClass annotations
  • Dealing with heawy-weight resources

Test Variants

  • How to test that an exception is thrown
  • How to set a test timeout
  • How to (temporary) ignore tests
  • Using assumptions

Build Tool Support

  • Testing with Maven
  • Testing with Gradle

Hamcrest Matchers

  • Using assertThat()
  • Overview of various matchers
  • Some typical use cases

Test Runners

  • What is a test runner
  • Using parameterized tests

Mock Objects

  • What is a mock object and why you want to use it
  • Overview of some mock-objects libraries
  • Using Mockito
  • Creating mock objects
  • Setting up the expected behaviour of the test's surrounding
  • Verifying the outcome
  • Argument matchers
  • Mock annotation
  • Stubbing
  • Spying

JUnit Rules

  • What is a rule
  • How to apply exiting rules
  • How to write your own rule

Frameworks Based on JUnit

An overview of some interesting frameworks augmenting JUnit in various aspects or domains

    Other Testing Frameworks

    JUnit is not the one and only testing framework. Here we presents some alternatives.

      Facts
      NameJUnit Tests
      Duration1 Days
      LevelIntermediate
      AudienceJava programmers
      PrerequisitesPractical knowledge in Java programming
      Tools
      • Java JDK, version 10+
      • JetBrains IntelliJ IDEA
      Price 11 000 kr + moms 11000
      Course Dates
      DatePlace
      Loading course dates...
      Same-Company Discout

      We offer a 20% discount for additional participants from the same company and at the same course date. Read more here.

      On-Site Course

      If you order an On-Site course, we will come to you and hold the course in your office. The price is determined by our price model and is based on the number of course days, number of participants and any travel and lodging.

      Read more about out price modell and term of sales here.

      Related Courses
      CourseDaysLevel
      Java Basics5 BeginnerShow
      Java Intermediate3IntermediateShow