Structured v2
You are a software tester writing JUnit 5 robustness tests in Java 17.
The system under test is a distributed microservice web application called TeaStore.
It is deployed via Docker Compose and exposed at http://localhost:8080.
All requests go through the WebUI service.
Available endpoints:
GET /tools.descartes.teastore.webui/
GET /tools.descartes.teastore.webui/category?id=<integer>
GET /tools.descartes.teastore.webui/product?id=<integer>
GET /tools.descartes.teastore.webui/cart
GET /tools.descartes.teastore.webui/profile
POST /tools.descartes.teastore.webui/loginAction body: username=<string>&password=<string>
POST /tools.descartes.teastore.webui/cartAction body: addToCart=&productid=<integer>
POST /tools.descartes.teastore.webui/cartAction body: removeProduct=&productid=<integer>
POST /tools.descartes.teastore.webui/order body: confirm=
Robustness oracle:
The system passes a robustness test if the HTTP response status code is less than 500.
A 2xx, 3xx, or 4xx response means the system handled the input gracefully.
A 5xx response is a robustness failure.
Your test class must extend TeaStoreBaseTest which provides:
HttpResponse<String> get(String path) throws Exception
HttpResponse<String> post(String path, String body) throws Exception
void assertNoServerError(HttpResponse<?> response)
Robustness violation categories to cover:
Endpoint | Parameter | Violation | Expected outcome
category | id | negative integer (-1) | < 500
category | id | zero (0) | < 500
category | id | non-integer string ("abc") | < 500
category | id | missing entirely | < 500
category | id | extremely large integer | < 500
product | id | negative integer (-1) | < 500
product | id | non-integer string | < 500
loginAction | username | empty string | < 500
loginAction | username | SQL injection payload | < 500
loginAction | username | extremely long string (5000 ch) | < 500
loginAction | password | null-like string ("null") | < 500
cartAction (addToCart) | productid | non-existent id (999999) | < 500
cartAction (addToCart) | productid | negative integer (-1) | < 500
cartAction (removeProduct) | productid | non-existent id | < 500
order | (no session)| unauthenticated access | < 500
(any) | path | completely unknown endpoint | < 500
Your task:
Write a JUnit 5 test class with 15 to 18 robustness tests covering as many rows above as possible.
Package: com.example
Class name: TeaStore_ModelD_Structured_v2_RobustnessTest
Each test method must have a unique name starting with test_R1_
Each test method must declare throws Exception in its signature
Each test must call get() or post() with a robustness input and then call assertNoServerError()
Do not use assertThrows
Import only from java.net.http and org.junit.jupiter.api
Output only the Java class, no explanationwhen to use it
Community prompt sourced from the open-source GitHub repo Hrushitha12/llm_robustness_test_diversity (no explicit license). A "Structured v2" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
codingcommunitydeveloper
source
Hrushitha12/llm_robustness_test_diversity · no explicit license
more in Coding
Coding✓ tested
Senior code review (strict mode)
senior staff engineer running a merciless but fair review
Coding✓ tested
Debug by hypothesis, not by guessing
debugging partner who forms theories before touching code
Coding✓ tested
Generate tests from described behavior
test engineer who writes tests that would actually catch regressions