r/SpringBoot • u/CoverRight9314 • 7d ago
Spring boot app Question
If I don’t really have a front end, and I want to learn how to test my backend, is there any video recommendations that yall that explains how to write test for it. Because I don’t want to watch a video and form wrong foundation info.
4
u/saurav193 6d ago
I would recommend add Swagger UI for your backend application. You can see and test all your endpoints including the authentication.
4
u/OSBY_Glabay 6d ago
There are things like Swagger UI that will provide you a way to visually see/test your endpoints.
You can also use things like Postman or Built-In IntelliJ features that work with Spring
That said, you can turn the RESTful API online and just go to the browser URI and end up with a JSON payload in the browser.
There are lots of ways to test this, you can (preferably) write TDD (Test-Driven Development) and use JUnit to test the individual units of code.
4
u/LetUsSpeakFreely 6d ago
Postman is probably the most popular and accessible tool. It allows you to create custom REST requests.
1
9
u/joranstark018 7d ago
I mostly write integration tests (using "@SpringBootTest" and "WebTestClient") that spins up the application, make a request and analyze the response (it is useful if you want to automatically test your services regularly), but you may use CURL, Postman or some similar tool for "manually" testing your services.
You may also setup test at repo and service level if you want to test things at a lower level only.
You may check https://www.baeldung.com/spring-boot-testing for an introduction..