Love your videos bro ❤ Thank you so much for all the Hard Work ❤💪
@Lykkos-3214 ай бұрын
you make this tutorial super easy to grasp and understand! thanks!
@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?
@songnicholas820711 ай бұрын
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?
@luizsaurin57029 ай бұрын
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.
@SorwestOuO8 ай бұрын
@@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?
@saladproblems7 ай бұрын
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.
@saladproblems7 ай бұрын
@@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.
@luizsaurin57027 ай бұрын
@@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.
@loadt44 ай бұрын
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?
@mateobro25404 ай бұрын
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
@TeddySmithDev4 ай бұрын
It’s up to you. You usually don’t test everything anyway. Just the most used parts of code base.
@GoshaLover-cr7vq4 ай бұрын
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
@mateobro25402 ай бұрын
@@TeddySmithDevThanks teddy. I really appreciate it