I did all these in my previous project, but spend lot of time behind test slicing stuff. You bootifully consolidated and explained that. thank you very much !
@FrancoisLacoursiere
6 жыл бұрын
Great video. I've been struggling doing these tests in the past, this is the first time I see something that summarizes testing with spring that well.
@Temofey1989
6 жыл бұрын
Great talk. Thank a lot, Josh. Looking forward to your video about Spring and JUnit 5.
@stealthmusic1
6 жыл бұрын
Watching his failed attempt to create a test configuration, I find it very satisfying that even Josh has problems to understand what’s happening under the hood.
@zephyrliu8833
5 жыл бұрын
I always feel confused about the test purposes, here are what i found in this material: 7:52 box and unbox an entity / 22:44 object returned from persistent layer is mapping right / 26:00 objects save to and retrieve from the repository layer are matched / 31:03 response object returned from controller layer match expectation.
@tetsuya8736
5 жыл бұрын
Great,, thank you...!!
@MuztabaHasanat
6 жыл бұрын
great video. looking forward to Junit 5 video.
@javasoccernut
6 жыл бұрын
depending on the pie, I might take the whole pie as a slice.
@vasiliydorofeev1355
5 жыл бұрын
So cool
@ramoo06
6 жыл бұрын
thanks
@anug14
6 жыл бұрын
Thanks
@michaelstruski1233
6 жыл бұрын
Hey Josh what about your usual "When your wife leaves you and your dog runs away - start dot spring dot io" ? When UFO kidnaps you and probes your butt - start dot spring dot io. When you wake up in a bathtub full of ice with one kidney - start dot spring dot io.
@gustavoponce990
6 жыл бұрын
Great talk!! Please keep posting this Kind of videos. One question... In this video you implemented the Controller (MockMvc) and the repository (@JpaTest + h2), so I would like to know what is your recommendation for applications with a service layer, use Mockito to mock the data layer?, Are there testing annotations related to service layer?
@RodrigoFielCapao
6 жыл бұрын
You could use @MockBean for mocking any class.
@bhps1203
5 жыл бұрын
One thing I dint understand, in ReservationJPATest you passed a reservation object in persistflushfind method with null id,? first is persistflushfind finds the object by id , how did it accept null? and next is you are checking for not null id in the object. it should return false as it has id: null in line 23
@abhisheks8017
5 жыл бұрын
When you pass an entity with null as id, it will be saved with a new generated Id value when persisting to database (because of the @GeneratedValue annotation).
@limpep
6 жыл бұрын
Is there an annotation to test Spring Security?
@vlorenzosoleri
6 жыл бұрын
Spring Security is built with Filters, so you would need the web layer to test it. By default, WebMvcTest fires up Spring Security, you can opt out of that with the secure parameter. There are annotations to test behaviour as a specific user or with a specific role, I recommend you check out the example projects on github and the documentation. I think there is also at least one video on the topic on this channel
@dentjoener
6 жыл бұрын
What if you're testing database specific functionality, let's say postgis with postgresql. How do you go about testing with an H2 database then? We run into this issue a lot and would like to know if there's a solution
@vasilievip
6 жыл бұрын
github.com/Playtika/testcontainers-spring-boot don't have postgresql yet, but this is what we use internally
@clintonmagro
6 жыл бұрын
So you should consider using Liquibase which will create the schema for you whether you run H2 for an Integration Test or a real production Postgres. Once you run your application and Liquibase does everything for you, it's just a matter of providing either a memory datasource url for H2 or a real datasource url for postgres. You can also make use of Spring Profiles to help with this however H2 shouldn't be allowed to be included in production even if you use postgres, ie; it should be scope test in your maven dependencies.
@pawelbial
6 жыл бұрын
You don't. In my opinion if you use any DB specific syntax or functions it's much easier to use same DB for testing. I used to have 2 DB instances on local Docker (one for development, one for tests). Then Flyway scripts were creating full schema when test suite execution started. It's good to have each test revert DB to initial state after it's execution. They tests should be fairly fast. Locally it works great. Unfortunately you cannot share one DB between multiple CI jobs. It can be solved by using Docker to instantiate new DB for each test job. It should be said that e.g. for Oracle it might be time consuming.
@yuanliu9700
6 жыл бұрын
what operating system do you use in your workstation?
@christophec8589
6 жыл бұрын
ubuntu
@Vermillionns
5 жыл бұрын
Let's add these two annotations and now the tests take 5 seconds to execute (for a single test) and we can't do tdd anymore...
Пікірлер: 27