Skip to content

Commit

Permalink
Merge branch 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangtien2k3 committed Sep 7, 2023
2 parents 7cad052 + dd2836e commit 38698e7
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Unit-Testing-JPA/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

## Spring Testing Framework

[ResultActions](): là một phần của Spring MVC Test framework trong Spring Framework, được sử dụng để kiểm tra và xác nhận kết quả của các yêu cầu HTTP trong quá trình kiểm thử (unit testing hoặc integration testing) của ứng dụng web.

- [andExpect](): Được sử dụng để xác nhận các điều kiện về kết quả trả về, chẳng hạn như kiểm tra mã trạng thái HTTP, kiểm tra view đã được render, kiểm tra model attribute, v.v.

- [andDo](): Cho phép bạn thực hiện các hành động bổ sung sau khi yêu cầu đã được xử lý. Thường được sử dụng để ghi log hoặc in ra nội dung trả về để kiểm tra.

- [andReturn](): Trả về kết quả của yêu cầu HTTP dưới dạng MvcResult, cho phép bạn truy cập đầy đủ thông tin về yêu cầu và trả lời để thực hiện các kiểm tra tùy chỉnh.

```java
@WebMvcTest(YourController.class)
public class YourControllerTest {

@Autowired
private MockMvc mockMvc;

@Test
public void testYourController() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/your-endpoint"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.view().name("your-view"))
.andExpect(MockMvcResultMatchers.model().attributeExists("yourAttribute"))
.andDo(MockMvcResultHandlers.print());
}
}
```

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Unit-Testing-JPA/test-springboot-blog-rest-api/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Unit-Testing-JPA/test-springboot-blog-rest-api/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Unit-Testing-JPA/test-springboot-blog-rest-api/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Unit-Testing-JPA/test-springboot-blog-rest-api/HELP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Read Me First
The following was discovered as part of building this project:

* The original package name 'com.hoangtien2k3.test-springboot-blog-rest-api' is invalid and this project uses 'com.hoangtien2k3.testspringbootblogrestapi' instead.

# Getting Started

### Reference Documentation
For further reference, please consider the following sections:

* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.1.3/maven-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.1.3/maven-plugin/reference/html/#build-image)
* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/3.1.3/reference/htmlsingle/index.html#data.sql.jpa-and-spring-data)
* [Spring Web](https://docs.spring.io/spring-boot/docs/3.1.3/reference/htmlsingle/index.html#web)
* [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/3.1.3/reference/htmlsingle/index.html#using.devtools)
* [Validation](https://docs.spring.io/spring-boot/docs/3.1.3/reference/htmlsingle/index.html#io.validation)

### Guides
The following guides illustrate how to use some features concretely:

* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/)
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
* [Accessing data with MySQL](https://spring.io/guides/gs/accessing-data-mysql/)
* [Validation](https://spring.io/guides/gs/validating-form-input/)

0 comments on commit 38698e7

Please sign in to comment.