~/talk

Testing Spring Boot Applications

Talkat Spring I/O 2016 · 2016-05-19..05-20· [testing, spring]
name:Phil Webb
links:none on file
slides:none on file

Starts with a slow full integration test hitting MySQL and a WireMock endpoint, then shows concrete moves to faster, clearer tests: use Spring Boot 1.4’s TestRestTemplate with random port, replace real DB with an in‑memory one via @DataJpaTest and TestEntityManager, stub REST calls with MockRestServiceServer and verify 404 handling, swap real services for Mockito mocks with @MockBean, and use JacksonTester/AssertJ for JSON checks. Examples run and pass, and each change measurably speeds tests and narrows surface under test.

AI-written summary · about

  1. 0:00Intro
  2. 3:02Remote Service
  3. 4:01Controller
  4. 4:41Repository
  5. 5:18Ymock
  6. 6:23Integration Test
  7. 7:04Configuration
  8. 8:01Upgrading
  9. 10:46Moving to Spring Boot
  10. 11:24Annotations
  11. 11:52Web Environment
  12. 12:36Spring Boot Test
  13. 12:51Dropback Classes
  14. 15:13Upgrade to assertJ
  15. 16:23What to import
  16. 17:45Remove autowire annotation
  17. 18:23Why use constructor injection
  18. 19:12Expecting exceptions
  19. 20:00Testing the message
  20. 20:31Consistent naming
  21. 21:25Mockito
  22. 22:23Constructor Style
  23. 22:56Testing
  24. 23:18Auto Configuration
  25. 23:56Vehicle Identification Number
  26. 24:21Naming Suggestions
  27. 24:33DataJPA
  28. 26:30Spring Data Repository
  29. 27:25Auto Configure
  30. 27:54Auto Configure with Existing Tests
  31. 28:12Shut Down MySQL
  32. 28:33Auto Configure Test Database
  33. 29:31Remote Services
  34. 30:13Rest Template Recap
  35. 30:34Protected Method
  36. 30:49Rest Service Server
  37. 31:19Happy Path
  38. 32:01Mocking
  39. 33:41JSON Test Setup
  40. 35:45Remote Service Test
  41. 35:59Testing Mocks
  42. 36:17Testing Integration
  43. 36:29Testing Service
  44. 37:53MockBean
  45. 38:25Mock injected
  46. 38:56Test results
  47. 39:12New features
  48. 39:41Web MVC annotation
  49. 40:38Mock MVC annotation
  50. 41:02Getting a vehicle
  51. 42:27Service Test
  52. 43:01Mock MVC Test
  53. 43:50Spring Boot MVC
  54. 45:24Compulsive Notation
  55. 46:33Balancing
  56. 47:02Mock Bean
  57. 47:14MachBeam
  58. 47:50Other Applications
  59. 48:07MetaAnnotations
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.