Week 7 Spring Test Flashcards

1
Q

What does Spring provide for testing?

A

Spring provides a module called spring-test, which is also included with Spring Boot projects by default, which makes doing tests such as integration tests and dao layer tests easy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What features does Spring test have?

A

Spring test gives features such as allowing us to test a fully integrated system as a whole using features such as providing an application context and dependency injection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Application Context? What are the tiers?

A

Application Context: responsible for instantiating, storing, and configuring (wiring) all of our beans together.

3 tier application:
    Controller
    Service
    Dao

We want to have these layers wired together through the application context (IoC container), so that we can perform integration testing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What annotations go on top of the Test classes?

A

@SpringBootTest: Loads an entire application context (the entire app, just like when you run the Spring Boot application normally)

@AutoConfigureMockMvc: Configures a MockMvc bean that can be injected into the test class in order to send mock HTTP requests to our fully configured WebApplicationContext

@DirtiesContext: Allows us to indicate that the application context needs to be reloaded (for example, so that we can start with a brand new database for each test)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is MockMvc?

A

MockMvc provides support for testing Spring MVC applications. It gives testers the ability to perform request handling through mock request objects and mock response objects rather than running an actual HTTP server (such as Tomcat).

We can utilize MockMvc to perform requests and check if the responses are what we should be expecting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly