From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Challenge: Test a Spring weather application
From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Challenge: Test a Spring weather application
(bright music) - [Instructor] Let's practice testing Spring Boot applications. With this challenge, you'll write unit tests and integration tests for a weather application. Let's take a look. The controller has a single endpoint that returns the current temperature for a given city from a weather service. To retrieve the weather data, it uses the weather service. Let's take a look at that. The weather service makes a get request to the open weather map API, using a REST template. We pass in the city name, the API key, and a unit for the measurement to ensure the temperature is returned in Fahrenheit. The API key is configured in our application.properties file. We pull it into our class with the at value annotation. There are also two model classes that represent the weather response and its corresponding attributes. Each of these classes should have a unit test and there should be an integration test for the full application. Be sure to consider everything you've learned so far when…
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
Walk through a basic Spring Boot application3m 53s
-
(Locked)
Write your first Spring Boot test3m 43s
-
(Locked)
Test Spring data repositories6m 1s
-
(Locked)
Test Spring services4m 9s
-
(Locked)
Test Spring controllers5m 58s
-
(Locked)
Integration testing with Spring Boot10m 40s
-
(Locked)
Best practices and tips for testing Spring Applications2m 9s
-
(Locked)
Challenge: Test a Spring weather application1m 8s
-
(Locked)
Solution: Test a Spring weather application16m 37s
-
(Locked)
-