-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathNotes.txt
More file actions
88 lines (56 loc) · 2.74 KB
/
Notes.txt
File metadata and controls
88 lines (56 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Sprint initializer: https://start.spring.io/
mvn clean install
mvn spring-boot:run
GET http://localhost:8080/api/books
POST http://localhost:8080/api/books
Content-Type: application/json
{
"title": "Spring Boot in Action",
"author": "Craig Walls",
"isbn": "9781617292545"
}
DELETE http://localhost:8080/api/books/1
Visit Swagger interface at: http://localhost:8080/swagger-ui.html
Good example documenting how to generate Swagger APIs in Spring Boot: https://bell-sw.com/blog/documenting-rest-api-with-swagger-in-spring-boot-3/#mcetoc_1heq9ft3o1v
Swagger UI: http://localhost:8080/swagger-ui.html
OpenAPI JSON: http://localhost:8080/v3/api-docs
Access front-end at: http://localhost:8080
1. Run all tests (Unit & Integration)
mvn test
This will execute all test cases in the src/test/java/ directory.
2. Run only Unit Tests
To run only unit tests, use:
mvn -Dtest=UserServiceTest,BookServiceTest test
mvn -Dtest=*ServiceTest test
3. Run only Integration Tests
To run only the integration test:
mvn -Dtest=LibraryIntegrationTest test
4. Run tests with detailed output
For more verbose output:
mvn test -Dspring-boot.run.profiles=test
This ensures your unit tests mock dependencies properly while integration tests interact with a real embedded server.
To run all tests, including performance tests, use:
mvn test
To run only performance tests, use:
mvn -Dtest=PerformanceTest test
Documentation on how to use Gatling: https://medium.com/thefreshwrites/getting-started-with-gatling-in-java-using-maven-b1664f6533d#:~:text=Gatling%20is%20a%20popular%20open,Gatling%20in%20Java%20using%20Maven.
Maven Commands to Run Tests and Generate Reports
Run all unit and performance tests
mvn test
Run JaCoCo test coverage report
mvn verify
mvn clean test jacoco:report # creates the report
mvn clean verify jacoco:report # if the check fails jacoco stops
Generate reports for testing, coverage, and code quality
mvn site
The reports will be available under target/site/index.html.
These changes enable test coverage (JaCoCo), static analysis (CheckStyle, PMD, JDepend), unit testing (Surefire), and performance testing (JUnitPerf).
mvn clean verify site
Then, open target/site/index.html, and the JaCoCo report should be available.
Very good explaination of the project
Reference: https://medium.com/@pratik.941/building-rest-api-using-spring-boot-a-comprehensive-guide-3e9b6d7a8951
Building REST services with Sprint: https://spring.io/guides/tutorials/rest
Docker example with Sprint:https://medium.com/@yunuseulucay/end-to-end-spring-boot-with-mysql-and-docker-2c42a6e036c0
Documentation about JaCoCo and Spring Boot
https://medium.com/@truongbui95/jacoco-code-coverage-with-spring-boot-835af8debc68
Documentation JUnitPerf: https://noconnor.github.io/JUnitPerf/docs/junit5.html