TDD/BDD Unit Test Example with Mockito and IntelliJ IDEA

  Рет қаралды 4,343

Brandan Jones

Brandan Jones

Күн бұрын

A hands-on example of using Mockito in a BDD/TDD unit test. We start by looking at a Given When Then example of saving an object. We translate that into a series of test methods. As we complete the test methods, we see additions we need to make to our service layer, and a new DAO and DAO layer that we need to make. We mock this DAO with Mockito, and then use the mocked DAO in the service class. We verify that our tests work against this mocked class. Next, we demonstrate how to validate that a method is invoked with Mockito's verify() method.
Source code is freely available on GitHub: github.com/dis...
This video is part of a playlist on Microservices and Spring Boot with IntelliJ IDEA: • IntelliJ IDEA, Git, Gi...

Пікірлер: 9
@mytubekt
@mytubekt Жыл бұрын
Thanks for sharing! Very informative.
@discospiff
@discospiff Жыл бұрын
Excellent! TDD is a great way for ensuring quality in your application. I hope you're building something awesome!
@ZionREI_CN
@ZionREI_CN 4 жыл бұрын
Thanks it's very fundamental and helpful, it would be great we have more clear guide from how to start a brand new project and work on it step by step until the test
@emaayan
@emaayan 3 жыл бұрын
from my POV this is extremely confusing, perhaps because i'm not aware of the BDD terminology, but the method names here mislead me. the "givenSepcimenDataAreAvailable" method means for me, that data is simply already available in the data store, but in fact this method simply sets up the mocking behavior of the class of taking the current data and saving it . the "whenUserCreatesaNewSpecimenAndSaves" doesn't do any creation nor is it the one that calls the save method .
@discospiff
@discospiff 3 жыл бұрын
Thanks for the feedback.
@caffeinejavacode1475
@caffeinejavacode1475 4 жыл бұрын
is it JUnit 5?
@Zapper024
@Zapper024 4 жыл бұрын
Yes, check the pom.xml for dependencies stackoverflow.com/questions/59193282/difference-between-junit-vintage-engine-and-junit-jupiter-engine
@josersleal
@josersleal 3 ай бұрын
why not just use cucumber? the value of BDD is to communicate with business and this is hand made developer only stuff. waste of time if no proper reporting is output.
@Nadirali-yc7yb
@Nadirali-yc7yb 4 жыл бұрын
Give me a shout out
How to TDD a REST API | Gil Zilberfeld (EN)
59:08
JAVAPRO
Рет қаралды 1,4 М.
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Better Java Streams with Gatherers - JEP Cafe #23
1:13:32
Don't Mock 3rd Party Code
19:56
Continuous Delivery
Рет қаралды 41 М.
Test Driven vs Behaviour Driven Development
5:01
Development That Pays
Рет қаралды 164 М.
Spring Boot Integration Test with TDD | JUnit5  & H2 | JavaTechie
45:27
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 918 М.
Unit Testing C# Code - Tutorial for Beginners
44:56
Programming with Mosh
Рет қаралды 619 М.