Skip to content

How to Test Endpoints

Subhrodip Mohanta edited this page Apr 3, 2026 · 1 revision

How to Test Endpoints

Testing is a critical part of our development lifecycle. You can verify endpoints using several methods.

1. Swagger UI (Recommended)

The easiest way to explore and test our APIs is via the built-in Swagger UI.

  • URL: http://localhost:8080/swagger-ui/index.html
  • Features: Interactive documentation, request generation, and response visualization.

2. Testing with JWT Authentication

Most endpoints require a valid JWT token.

  1. Authenticate: Send a POST request to /authenticate with your credentials.
  2. Copy Token: Copy the jwt value from the response.
  3. Authorize: In Swagger UI, click the Authorize button and paste the token as Bearer <your_token>.
  4. Request: Now you can call protected endpoints like /users or /posts.

3. Automated Integration Tests

We use Spring Boot Test for full-stack integration testing.

  • Location: src/test/java/xyz/subho/clone/twitter/
  • Run Command:
    ./mvnw test

The test profile uses an in-memory H2 database, so no external setup is required for these tests.

4. Manual testing with cURL

Example of fetching posts with a token:

curl -X GET "http://localhost:8080/posts?page=0&size=10" \
     -H "Authorization: Bearer <your_jwt_token>"

Clone this wiki locally