Spring Boot : Integration tests with environment variables

Omkar Birade
interleap
Published in
4 min readNov 7, 2019

--

If you want to read about setting up an EmailService which reads the credentials from environment variables please refer to my article on:

Spring Boot : Configuring environment variables

Writing integration tests for an EmailService

Now that our code works, we want to write an integration test for EmailService.

It can be done using GreenMail which creates a SMTP server for us and receives all the emails we send through our test.

You can read about about GreenMail here:

So let’s see how our EmailServiceTest class looks like:

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class…

--

--

Omkar Birade
interleap

Co-Founder at Interleap. I write to learn more.