Spring Boot Unit Testing With Mockito - Repository [Part 2]

  Рет қаралды 22,239

Teddy Smith

Teddy Smith

Күн бұрын

Пікірлер: 15
@franky3557
@franky3557 Жыл бұрын
Love your videos bro ❤ Thank you so much for all the Hard Work ❤💪
@Lykkos-321
@Lykkos-321 4 ай бұрын
you make this tutorial super easy to grasp and understand! thanks!
@sonukumarpandit9731
@sonukumarpandit9731 Ай бұрын
I think get method returns entity if found otherwise throw some exception, and we are not checking that exception in case Pokemon is not found, am I correct?
@songnicholas8207
@songnicholas8207 11 ай бұрын
Will not connecting to the real database lead to a wrong "correct result" ? In fact, web applications should connect to the database. Is it a ideal way to use in-memory simulated database?
@luizsaurin5702
@luizsaurin5702 9 ай бұрын
This depends on the developer's objective and the needs of the project. I think in this case he is using the in-memory database to speed things up, considering it is just a learning class. But yes, it is good practice to run tests on the real database that will be used in production.
@SorwestOuO
@SorwestOuO 8 ай бұрын
@@luizsaurin5702 But doesnt it write unwanted data into the production DB? If connecting to Prod DB then when you mess up the tests the prod DB will be impacted. is it really ok?
@saladproblems
@saladproblems 7 ай бұрын
You're not wrong, but that's where I personally draw the line between unit and integration tests. Ideally you'd have some separate integration tests or health indicators to cover the state of the real-world databases. In our environment we have multiple build pipelines which have their build agents running on a variety of different platforms. Hopefully we can consolidate them, but as-is the build agent could be an OpenShift pod, a thick agent on a persistent windows or linux VM, or whatever build agents AWS does (my team isn't using them). Not all of those resources have or should have access to real databases, and our nonprod databases don't have rigid uptime requirements, so if I run a nightly build, it's going to fail a few times a month during patching or other outages and generate some noise.
@saladproblems
@saladproblems 7 ай бұрын
​@@SorwestOuO From stack overflow: "Annotating a test method with @Transactional causes the test to be run within a transaction that will, by default, be automatically rolled back after completion of the test. If a test class is annotated with @Transactional, each test method within that class hierarchy will be run within a transaction." There's some other setup needed to make this work, so do you research first, but the functionality is there. Personally I would only perform these transactions against a nonprod DB just in case.
@luizsaurin5702
@luizsaurin5702 7 ай бұрын
@@saladproblems Fair. In the case where I work, the test databases are only active during business hours, and the contracting client requires that the tests use these databases. It's like I said before, each company works differently, and I believe that Spring can adapt to different cases, just like the one you mentioned.
@loadt4
@loadt4 4 ай бұрын
when you were testing for the update pokemon method, you did assertions only for the local variable's fields that are not null. Shouldn't you get the updated pokemon from the DB and test that the actual update in the DB worked?
@mateobro2540
@mateobro2540 4 ай бұрын
Hi, i have a question. do we really need to test the repository layer? I mean, we didn't code this layer we just use it
@TeddySmithDev
@TeddySmithDev 4 ай бұрын
It’s up to you. You usually don’t test everything anyway. Just the most used parts of code base.
@GoshaLover-cr7vq
@GoshaLover-cr7vq 4 ай бұрын
You really don't, those are really well tested already lol, only if you wrote actual SQL querys there. But it's good and simple for learning
@mateobro2540
@mateobro2540 2 ай бұрын
​@@TeddySmithDevThanks teddy. I really appreciate it
Spring Boot Unit Testing With Mockito - Repository [Part 3]
14:31
Junit in 1 Minute
1:01
in28minutes
Рет қаралды 37 М.
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН
Spring Boot Unit Testing With Mockito - Mocking Explained
15:30
Teddy Smith
Рет қаралды 35 М.
Java Unit Testing with JUnit - Tutorial - How to Create And Use Unit Tests
21:35
Spring Boot Unit Testing With Mockito - Repository [Part 1]
9:44
Why OOP is evolving(and why it's a good thing)
7:35
TMF
Рет қаралды 16 М.
Spring Boot Unit Testing With Mockito - 1. First Unit Test
14:42
Teddy Smith
Рет қаралды 110 М.
What is JUnit? | Why Mockito?
14:38
Telusko
Рет қаралды 375 М.
What does larger scale software development look like?
24:15
Web Dev Cody
Рет қаралды 1,5 МЛН
Unit Testing in Spring Boot with JUnit 5 and Mockito | Part 1
30:37