Course Duration: 3 Days
Course Outline:

JUnit 4  Overview

  • Lifecycle annotations
  • assertEquals, assertTrue, assertFalse, AssertSame
  • Testing exceptions, using @Rule
  • Hamcrest Matchers and assertThat
  • Parameterized Tests
  • Theories

JUnit 5 Overview 

JUnit Vintage and Jupiter

  • Lifecycle annotations
  • Grouped assertions and nested Grouped Assertions
  • Exception testing
  • @EnableOn, @DisableOn, @EnableIf
  • @ParameterizedTest using method sources

Stubs and Mocks

Making Code Testable

  • Creating Fake Dependencies

Mockito

  • Creating Mock Objects
  • MockitoAnnotations
  • @Mock
  • @InjectMocks
  • Partial Mock or @Spy
  • ArgumentCaptors @Captor

Spring Boot, Testing Controllers and RestControllers

Core Spring testing

  • JUnit4
    • @RunWith(SpringJUnit4ClassRunner.class)
    • @ContextConfiguration
  • JUnit5
    • @ExtendWith(SpringExtension.class)
    • @ContextConfiguration

Testing Running Spring Boot Services

  • RestTemplate
    • getForObject, getForEntity
    • postForEntity
    • exchange
    • Setting headers
    • Consuming a Response
    • Content Negotiation
  • WebClient (Spring 5)
    • Building a ResponseSpec for Get and Post requests
    • WebFlux and using Mono in our tests
    • Content Negotiation with ResponseSpec
    • Subscribing to the Mono of the Response
    • Using retrieve and exchange
  • Spring Services Unit testing
    • @WebApplicationConfiguration
      • MockMvcBuilders and MockMvcRequestBuilders
      • Standalone Controller and WebApplicationContext
    • ResultActions, expected results
    • Viewing the Response, MockMvcResultMatchers.JsonPath
    • @MockBean, mocking dependencies of the ApplicationContext
    • @WebMvcTest
    • Testing a JPARepository with MockObjects
  • Integration Testing with @SpringBootTest
    • TestRestTemplate
    • Get and POST Requests
  • Testing a Spring Cloud Eureka Registered Service
    • Disable Eureka Registration (Discovery Client)
    • Using Mock Objects
    • Testing a Feign Client Service

Integration Testing with Cucumber JVM

  • Gherkin basics
  • Feature and Scenario using Mocks
  • Scenario Outline
  • Testing Spring Boot Services with Cucumber and @SpringBootTest

JUnit 4  Overview

  • Lifecycle annotations
  • assertEquals, assertTrue, assertFalse, AssertSame
  • Testing exceptions, using @Rule
  • Hamcrest Matchers and assertThat
  • Parameterized Tests
  • Theories

JUnit 5 Overview 

JUnit Vintage and Jupiter

  • Lifecycle annotations
  • Grouped assertions and nested Grouped Assertions
  • Exception testing
  • @EnableOn, @DisableOn, @EnableIf
  • @ParameterizedTest using method sources

Stubs and Mocks

Making Code Testable

  • Creating Fake Dependencies

Mockito

  • Creating Mock Objects
  • MockitoAnnotations
  • @Mock
  • @InjectMocks
  • Partial Mock or @Spy
  • ArgumentCaptors @Captor

Spring Boot, Testing Controllers and RestControllers

Core Spring testing

  • JUnit4
    • @RunWith(SpringJUnit4ClassRunner.class)
    • @ContextConfiguration
  • JUnit5
    • @ExtendWith(SpringExtension.class)
    • @ContextConfiguration

Testing Running Spring Boot Services

  • RestTemplate
    • getForObject, getForEntity
    • postForEntity
    • exchange
    • Setting headers
    • Consuming a Response
    • Content Negotiation
  • WebClient (Spring 5)
    • Building a ResponseSpec for Get and Post requests
    • WebFlux and using Mono in our tests
    • Content Negotiation with ResponseSpec
    • Subscribing to the Mono of the Response
    • Using retrieve and exchange
  • Spring Services Unit testing
    • @WebApplicationConfiguration
      • MockMvcBuilders and MockMvcRequestBuilders
      • Standalone Controller and WebApplicationContext
    • ResultActions, expected results
    • Viewing the Response, MockMvcResultMatchers.JsonPath
    • @MockBean, mocking dependencies of the ApplicationContext
    • @WebMvcTest
    • Testing a JPARepository with MockObjects
  • Integration Testing with @SpringBootTest
    • TestRestTemplate
    • Get and POST Requests
  • Testing a Spring Cloud Eureka Registered Service
    • Disable Eureka Registration (Discovery Client)
    • Using Mock Objects
    • Testing a Feign Client Service

Integration Testing with Cucumber JVM

  • Gherkin basics
  • Feature and Scenario using Mocks
  • Scenario Outline
  • Testing Spring Boot Services with Cucumber and @SpringBootTest