Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Testing Spring Boot Applications
Search
Andy Wilkinson
October 09, 2019
Programming
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Testing Spring Boot Applications
Andy Wilkinson
October 09, 2019
More Decks by Andy Wilkinson
See All by Andy Wilkinson
Mastering Spring Boot's Actuator | Spring IO 2018
ankinson
4
1.5k
Documenting RESTful APIs
ankinson
4
1.2k
Documenting RESTful APIs – Webinar
ankinson
9
9.6k
Documenting RESTful APIs – Spring Exchange 2014
ankinson
4
1.3k
Other Decks in Programming
See All in Programming
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
260
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
3
1.4k
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
1.8k
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
5.5k
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
4
1.7k
私なりのハーネスエンジニアリング ~独自の言語処理系の開発を通して~
seosoft
0
170
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.6k
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
400
Web Framework Benchmark Battle 2026, Any%
a_matsuda
3
3.1k
まずはコードより業務と向き合う:テーブル解体のためにPdMを呼んだ話
sakawe_ee
0
100
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
110
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
5
5k
Featured
See All Featured
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
920
The Invisible Side of Design
smashingmag
301
52k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Code Review Best Practice
trishagee
74
20k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
So, you think you're a good person
axbom
PRO
2
2.2k
GitHub's CSS Performance
jonrohan
1033
470k
How to Ace a Technical Interview
jacobian
280
24k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
520
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
390
Building Adaptive Systems
keathley
44
3.3k
Designing for Timeless Needs
cassininazir
1
540
Transcript
Testing Spring Boot Applications Andy Wilkinson @ankinson
@ankinson Why Bother Testing At All?
@ankinson
@ankinson Risk None YOLO Tests 0 Lots
@ankinson
@ankinson Unit Tests
@ankinson
@ankinson MockRestServiceServer OkHTTP’s MockWebServer Spring Data Repositories JdbcTemplate
@ankinson Testcontainers
@ankinson https://www.testcontainers.org
@ankinson @SpringBootTest @Testcontainers(disabledWithoutDocker = true) @ContextConfiguration(initializers = ExampleIntegrationTests.Initializer.class) class ExampleIntegrationTests
{ @Container public static CassandraContainer<?> cassandra = new CassandraContainer<>(); static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { @Override public void initialize(ConfigurableApplicationContext context) { int cqlPort = cassandra.getMappedPort(CassandraContainer.CQL_PORT); TestPropertyValues.of("spring.data.cassandra.port=" + cqlPort) .applyTo(context.getEnvironment()); } } }
@ankinson Integration Tests
@ankinson @SpringBootTest
@ankinson Context Caching
@ankinson @SpringBootTest(properties="spring.jmx.enabled=true") @ActiveProfiles("standalone") @TestPropertySource(locations="standalone.properties") class ExampleIntegrationTests { @Test void contextLoads()
{ } } @ContextConfiguration @Import @TestPropertySource @ActiveProfiles @SpringBootTest
@ankinson @DirtiesContext
@ankinson Sliced Tests
@ankinson @JsonTest @WebMvcTest @WebFluxTest @DataJpaTest @JdbcTest @JooqTest @DataMongoTest @DataNeo4jTest @DataRedisTest
@DataLdapTest @RestClientTest
@ankinson @WebMvcTest @DataJpaTest OrderRepository extends JpaRepository<…> @Controller OrderController @Controller CustomerController
CustomerRepository extends JpaRepository<…> @SpringBootApplication Application
@ankinson @MockBean and @SpyBean
@ankinson @WebMvcTest class CustomerControllerIntegrationTests { @Autowired private MockMvc mockMvc; @Configuration
static class RepositoryConfiguration { @Bean CustomerRepository customers() { return mock(CustomerRepository.class); } @Bean OrderRepository orders() { return mock(OrderRepository.class); } } }
@ankinson Customer Customer Order @WebMvcTest class CustomerControllerTests { @Autowired private
MockMvc mockMvc; @MockBean private CustomerRepository customers; @MockBean private OrderRepository orders; } (controllers = CustomerController.class)
JUnit 5: Evolution and Innovation Sam Brannen Thursday 10:30am–11:40am Ballroom
F
Thanks! Q&A Andy Wilkinson @ankinson #springone @s1p