Back
Close

JUnit5 & Mockito

Akshat0210
2,199 views

Welcome!

This playground lets you get started quickly with a simple working example using Maven and JUnit5.

Hands-on Exercise

  • Write an assertion to compare two String are equal.
  • Write an assertion to check null.
  • Write an assertion to check equality of two byte array.
Assertions in JUnit5
// {...}
class AssertionsInJUnitFiveTest {...}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

HamCrest API Matchers

  • Write a HamCrest Matcher to check Map has key “John”
  • Write a HamCrest Matcher to check Map has entry “John , J”
Using HamCrest in JUnit5
// {...}
class HamcrestMatchersTest {
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Mockito in JUnit 5

  • Write Mockito Based test case for Messenger class
Mockito in JUnit5
// {...}
class MessengerTest {
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants