Unit and Integration Tests in Spring Boot JPA Example | Tech Primers

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ก.ย. 2017
  • This video covers how to write Unit tests and Integrations in Spring Boot Application which uses Spring Data JPA.
    📌 Related Playlist
    ================
    🔗Spring Boot Primer - • Spring Boot Primer
    🔗Spring Cloud Primer - • Spring Cloud Primer
    🔗Spring Microservices Primer - • Spring Microservices P...
    🔗Spring JPA Primer - • Spring JPA Primer
    🔗Java 8 Streams - • Java 8 Streams
    🔗Spring Security Primer - • Spring Security Primer
    🔗Containers Primer - • Containers Primer
    🔗Kubernetes Primer - • Kubernetes Primer
    🔗AWS Primer - • AWS Primer
    💥Join TechPrimers Slack Community: bit.ly/JoinTechPrimers
    💥Telegram: t.me/TechPrimers
    💥TechPrimer HindSight (Blog): / techprimers
    💥Website: techprimers.com
    💥Slack Community: techprimers.slack.com
    💥Twitter: / techprimers
    💥Facebook: TechPrimers
    💥GitHub: github.com/TechPrimers or techprimers.github.io/
    🎬Video Editing: iMovie
    🎼Background Music: Broke For Free - Day Bird
    brokeforfree.bandcamp.com/tra...
    The Passion HiFi - What We Came To Do
    Joakim Karud
    ---------------------------------------------------------------
    🔥 Disclaimer/Policy:
    The content/views/opinions posted here are solely mine and the code samples created by me are open sourced.
    You are free to use the code samples in Github after forking and you can modify it for your own use.
    All the videos posted here are copyrighted. You cannot re-distribute videos on this channel in other channels or platforms.
    #Testing #SpringBoot #TechPrimers
  • แนวปฏิบัติและการใช้ชีวิต

ความคิดเห็น • 89

  • @samarthurs8000
    @samarthurs8000 5 ปีที่แล้ว +1

    Thanks a lot, brother. Your videos are very informative.

  • @andrzejokon1517
    @andrzejokon1517 6 ปีที่แล้ว +3

    Great tutorial. Thank you!

  • @fairozahmed6888
    @fairozahmed6888 6 ปีที่แล้ว +3

    Very helpful. Thank you so much :)

  • @junysanteliz3796
    @junysanteliz3796 4 ปีที่แล้ว +3

    Thank YOU for this! Excellent content. Very well taught! You just earned yourself a subscriber my man

  • @ScoobyDoo-ct9nd
    @ScoobyDoo-ct9nd 4 ปีที่แล้ว +1

    your tutorials are good ..keep doing thanks

  • @sangkim6338
    @sangkim6338 5 ปีที่แล้ว +1

    Thanks for the good video. There is one part that I don't quite seem to get - when do you put data into the h2 DB you configured?

  • @richardlanglois5183
    @richardlanglois5183 6 ปีที่แล้ว +1

    Very informative!

  • @isidme
    @isidme 6 ปีที่แล้ว

    Hey Thanks... How can we write Integration test when JWT security is enabled

  • @yveromeev
    @yveromeev 6 ปีที่แล้ว +1

    thank you very much!

  • @maryonmayor
    @maryonmayor 6 ปีที่แล้ว

    how do u do when u need to test a post via a form? and having an element that is an array.

  • @stephaneislistening6103
    @stephaneislistening6103 6 ปีที่แล้ว

    What if we don't want to use the TestPropertySource annotation ? Is there any alternative way ?

  • @gurugovindgarg3771
    @gurugovindgarg3771 3 ปีที่แล้ว

    👍, can you suggest how to test interface projection jpa bz we can’t set value directly to interface field

  • @bookswiper
    @bookswiper ปีที่แล้ว

    Great insight besides learning about unit and integration test

  • @KiranInEurope
    @KiranInEurope 6 ปีที่แล้ว

    can you create same unit and integration testing Spring Boot Integration DSL using microservices

  • @abinashdhal9103
    @abinashdhal9103 4 ปีที่แล้ว

    Hi ,
    I have been given a task to implement and the task as follows .
    I need to integrate Spring cloud contract test to the existing project and the auto generated tests have to be validated against data in the in memory database(h2).
    i have integrated the contract testing to the existing project . can you give quick suggestion to implement the rest of it and if you could make a video which i know might take long time.
    Thanks in advance.

  • @amitsinha4159
    @amitsinha4159 4 ปีที่แล้ว

    Hi Sir,
    Could you please make a video for following use case Spring boot application with Mongo db integration but when we perform search operation then via elastic search we should retrieve record for performance reasons.
    I'm little confused here how to deal with this.
    Thanks in Advance

  • @NikitaKoselev
    @NikitaKoselev 4 ปีที่แล้ว +1

    Good stuff. Still useful.

  • @mo9204
    @mo9204 4 ปีที่แล้ว

    Tell us when you use Jpa over CrudRepository ?

  • @haricharanreddy1633
    @haricharanreddy1633 3 ปีที่แล้ว

    Hey at 4:56 what if am mocking a method which returns map
    Collections. emptyList() is giving error

  • @bandapalliharish155
    @bandapalliharish155 6 ปีที่แล้ว +2

    Nice video...... also can you please post a video related to testing of spring boot security which uses daoAunthenticationprovider

  • @venkatch2584
    @venkatch2584 5 ปีที่แล้ว

    Hi bro, your videos are useful, learn a lot. do you any videos for READY API test cases??

  • @rajum2195
    @rajum2195 ปีที่แล้ว

    thanks for a good video,your explanation is so nice,can you make a video for integration testing for a quarkus project

  • @palashkhatri7820
    @palashkhatri7820 6 ปีที่แล้ว +1

    Nice video got the concept

  • @asifimam8174
    @asifimam8174 3 ปีที่แล้ว

    kindly write some JPA unit test cases for Transactional Propagation Level and ISOLATION Levels and Level1 and Level 2 Cache Coverage

  • @amarreddy09
    @amarreddy09 4 ปีที่แล้ว

    Hi .. can you please do session on spring batch+jpa+h2 testing ... Thanks

  • @vishalkadam8722
    @vishalkadam8722 2 ปีที่แล้ว +1

    Very helpful.. Thanks for informative video.

    • @TechPrimers
      @TechPrimers  2 ปีที่แล้ว

      Glad it was helpful!

  • @puneetnamdeo
    @puneetnamdeo 6 ปีที่แล้ว

    please provide spring security with mockito.

  • @kirankumarkavali3897
    @kirankumarkavali3897 2 ปีที่แล้ว

    Hi, Can you please make a video on how to test spring batch application using spring boot and Junit

  • @shakib_04
    @shakib_04 2 ปีที่แล้ว

    are you sure webmvctest annotation is only for unit test not for integration test?

  • @Turnpost2552
    @Turnpost2552 4 ปีที่แล้ว +5

    Really likes the song in the background.

  • @valentineezugu7211
    @valentineezugu7211 6 ปีที่แล้ว

    @RequestMapping("/bookInfo" )
    public String bookInfo(@RequestParam("id") Long id, Model model) {
    Book book = bookService.findOne(id);
    model.addAttribute("book", book);
    return "bookInfo";
    }
    can some one test this controller just learning how to test? thanks

  • @virtexamit
    @virtexamit 6 ปีที่แล้ว +2

    Nice video, can you make a video covering unit/integration test for shopping cart or something a bit complex application where in we have multiple flows hence multiple UT n integration test classes.

    • @TechPrimers
      @TechPrimers  6 ปีที่แล้ว

      sure. wil try amit

    • @virtexamit
      @virtexamit 5 ปีที่แล้ว

      Thanks a lot can you also trying a demo with sample test data. For e.g. metadata is prerequisite before running integration tests.

  • @TheMikewonder1
    @TheMikewonder1 6 ปีที่แล้ว +1

    Hi, please can you make a video on how to test a web application using spring boot and Junit.

    • @TechPrimers
      @TechPrimers  6 ปีที่แล้ว

      Hi Daniel, you can find it here - th-cam.com/video/8S8o46avgAw/w-d-xo.html

  • @AhmadIsyfalanaAmin
    @AhmadIsyfalanaAmin 5 ปีที่แล้ว +1

    Great tutorial.
    Would you like to add subtitles to this video?

  • @mohammedsufi4649
    @mohammedsufi4649 5 ปีที่แล้ว

    Thank you for this video also please explain how mockMvc.perform() method worked in unit testing without @AutoConfigureMockMvc annotation, why should we use that in Integration testing alone even though we are autowiring the object?...

    • @vedikaashtekar4356
      @vedikaashtekar4356 2 ปีที่แล้ว +1

      I think WebMvcTest includes both both the @AutoConfigureWebMvc and the @AutoConfigureMockMvc. Correct me if I am wrong.

    • @javatips5979
      @javatips5979 2 ปีที่แล้ว

      @@vedikaashtekar4356 yes that is right

  • @BM-pz4mt
    @BM-pz4mt ปีที่แล้ว

    Hi sir, please can you explain Spring Batch unit and Integration testing in detailed.

  • @stepantzov
    @stepantzov 6 ปีที่แล้ว

    Hi, thanks for sharing this! but why you do not have @ContextConfiguration?

    • @TechPrimers
      @TechPrimers  6 ปีที่แล้ว

      yeah it was an older notation

  • @prasadchaudhari2063
    @prasadchaudhari2063 5 ปีที่แล้ว

    how we can up spring boot context once and use same context for all junits?

    • @TechPrimers
      @TechPrimers  5 ปีที่แล้ว

      You can create an abstract implementation and use that in all the tests

  • @manggalawiryawan3242
    @manggalawiryawan3242 6 ปีที่แล้ว

    Can i make contextLoads more than one?or i make other method same like contextLoads?

    • @TechPrimers
      @TechPrimers  6 ปีที่แล้ว

      no you cannot do it load more than once in the same test

  • @sanjaykantheti4002
    @sanjaykantheti4002 5 ปีที่แล้ว +1

    If time permits could you make a video on powerMockito as well.

    • @TechPrimers
      @TechPrimers  5 ปีที่แล้ว +1

      Sure will do

    • @sanjaykantheti4002
      @sanjaykantheti4002 5 ปีที่แล้ว

      @@TechPrimers Thanks Ajay!! Your channel is very informative and been following from past 1 year. keep going :)

  • @DigvijayBhakuni-1990
    @DigvijayBhakuni-1990 6 ปีที่แล้ว +1

    do video on spring data pipelining using spring XD and Data Flow

  • @karthikeyanthiruvoosivanai3181
    @karthikeyanthiruvoosivanai3181 6 ปีที่แล้ว

    Getting below error when execute unit testing test case
    Failed tests:
    SpringbootRestMockitoIntegrationtestApplicationTests.contextLoads:40
    Wanted but not invoked:
    com.tsk.springboot.mockito.resource.UserRepository#0 bean.findAll();

    • @TechPrimers
      @TechPrimers  6 ปีที่แล้ว

      Looks like findAll()is not getting mocked

  • @Jay-br2ud
    @Jay-br2ud 3 ปีที่แล้ว +1

    Great

  • @machhindraneupane9207
    @machhindraneupane9207 6 ปีที่แล้ว +1

    Sir make a video on resttemplet with form authentication spring boot

  • @princegovind
    @princegovind ปีที่แล้ว

    Bro , How to reduce Test execution time in build time of springBoot ..?

    • @TechPrimers
      @TechPrimers  ปีที่แล้ว +1

      One option is you can make tests run in parallel

  • @farhaankazi7134
    @farhaankazi7134 4 ปีที่แล้ว +1

    great

  • @supunkavinda8660
    @supunkavinda8660 6 ปีที่แล้ว +1

    hi sir, can you do spring boot batch tutorial.

  • @RonaLz4
    @RonaLz4 5 ปีที่แล้ว +2

    But, is it really an integration test?
    I mean, okay. We test from the endpoint all the way to the repository, but with an h2. My point is, that sometimes doing "integration" tests with an H2 database, are in someway integration, but you are testing with a non-productive database.
    Anyway, that was just a thought :D
    Great video!

    • @skaffen
      @skaffen ปีที่แล้ว

      An integration test is testing two elements of code. Yes it is. It doesn't have to be end to end

  • @dileepalla6769
    @dileepalla6769 6 ปีที่แล้ว +1

    can u post an vedio on how maven works?

    • @TechPrimers
      @TechPrimers  6 ปีที่แล้ว +1

      I have done that today. checkout the latest video

    • @dileepalla6769
      @dileepalla6769 6 ปีที่แล้ว

      i see that vedio thx

    • @dileepalla6769
      @dileepalla6769 6 ปีที่แล้ว

      can u post an example on google cloud how to host our application in google cloud with step by step

  • @rameshc6074
    @rameshc6074 10 หลายเดือนก่อน

    Where is the assertion for integration test

  • @ganeshpasupuleti5485
    @ganeshpasupuleti5485 4 ปีที่แล้ว

    can we unit test a spring jpa repository??

    • @TechPrimers
      @TechPrimers  4 ปีที่แล้ว

      Yes you can. But you end up mocking the DB part

  • @d2k2
    @d2k2 7 หลายเดือนก่อน

    so.. right?

  • @jhonnyjamifernandez447
    @jhonnyjamifernandez447 5 ปีที่แล้ว

    please enable automatic translation,
    Your videos are great but I'm not very good in English

  • @SandeepPandey-ku4mg
    @SandeepPandey-ku4mg 6 ปีที่แล้ว +2

    good tutorial....please follow proper TDD approach to write the test first, than come to implementation, i.e. Fail-Pass-Refactor cycle

  • @shihm4013
    @shihm4013 6 ปีที่แล้ว

    had to mute because of the buzzing/ringing sound

  • @vedikaashtekar4356
    @vedikaashtekar4356 2 ปีที่แล้ว

    Video is really good and helpful but the background music is really very disturbing. Without music it can be really good learning!

  • @andrii_popov
    @andrii_popov 4 ปีที่แล้ว +4

    @WebMvcTest is the most useless test type in the whole Spring Framework, it tests no logic, I cannot image you forget to invoke service method in your controller)

    • @BharCode09
      @BharCode09 4 ปีที่แล้ว +2

      Infact many mocking tests are useless and highly time consuming to write when called this, do that, blah blah! I slways do integration testing after unit testing.

  • @DudeMcSky
    @DudeMcSky 3 ปีที่แล้ว

    These are integration tests.

    • @skaffen
      @skaffen ปีที่แล้ว

      As mentioned in title.

    • @DudeMcSky
      @DudeMcSky ปีที่แล้ว

      @@skaffen well technically the title says "Unit and Integration tests" ...there are no unit tests here.

  • @mrchow3177
    @mrchow3177 4 ปีที่แล้ว

    If you use inteligay this wont work right of the bat..

  • @mertyertugrul
    @mertyertugrul 4 ปีที่แล้ว +2

    I like your tutorials, very helpful. But I really wish that you could pronunciate better, it is really hard to understand your accent.

    • @farhaankazi7134
      @farhaankazi7134 4 ปีที่แล้ว +2

      This is Indian English accent. Most of us speak in this way. Neutralizing English is bit difficult and take time. It is required.

  • @faN4t1k
    @faN4t1k 6 ปีที่แล้ว

    your music is annoying