What the agent does
In a multi-module build like spring-petclinic/spring-petclinic-microservices, the agent maps each changed file to its Maven module and reads the methods the diff touches, such as createOwner, findOwner and updateOwner in OwnerResource.java, which has no test class at all. It models new tests on PetResourceTest and VisitResourceTest: @WebMvcTest slices with @ActiveProfiles("test"), repositories replaced by @MockitoBean, assertions through MockMvc and jsonPath.
The root pom.xml inherits spring-boot-starter-parent 4.0.1 on Java 17, so it imports WebMvcTest from Boot 4's org.springframework.boot.webmvc.test.autoconfigure. The customers, vets and visits services' application-test.yml turn off Config and Eureka and load db/hsqldb/schema.sql, which a @DataJpaTest for a repository change uses as is.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "This pull request changes the customers and visits services. Read its diff against the base branch, taking the head and base commits from the pull request itself, and list the new or changed behavior no test covers, with file and line. Write JUnit 5 tests for it in each module's src/test/java, in the style of PetResourceTest and VisitResourceTest: @WebMvcTest slices with @ActiveProfiles(\"test\") and MockMvc for controllers, @DataJpaTest for repository changes. Cover success responses, @Valid failures that return 400, @Min path checks and not-found cases. Run ./mvnw -pl <changed modules> test until they pass, then ./mvnw test. Change nothing under src/main, do not commit or push, and do not open a pull request. Post one review on the pull request that lists each untested behavior with file and line, the test that covers it, the Maven result, and the new tests as one patch. A test that fails because the change is wrong goes in the review as a possible bug. If this run names no pull request, in resources or after this prompt, stop and say so.",
"resources": [
{
"url": "https://github.com/your-org/your-app/pull/123"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is one review on the pull request and nothing pushed. It lists each untested endpoint or query by file and line, the test class and method written for it, and the Surefire summary from ./mvnw test. The patch is in the review.
Left to the reviewer: whether to apply the patch, and, for a test the review reports failing, whether the controller is wrong or the test expects a status the API never promised.
Run it on every pull request opened against main
An automation with this request as its prompt and a github trigger on pull_request.opened and pull_request.synchronize, branch_patterns main (the repository's default branch), reviews each new pull request and each push to one. Work by an owner, member or collaborator fires it; a fork's pull request does not. The event gives the pull request's URL, title, author, labels and base branch without commit SHAs, so the prompt has the agent read the head and base from that URL.
The use case this job follows, with its automation and trigger: Review every pull request.
Why run it on Rush?
Most Spring testing examples online still import Boot 3's packages and @MockBean, which this Boot 4.0.1 build no longer compiles. The agent copies the imports from the module's own tests and proves them with ./mvnw per pull request, so a patch that compiles in the review compiles on the branch.
Frequently asked questions
Does it start the whole microservice stack?
No. Slice tests load one controller or the JPA layer, and the test profile disables Spring Cloud Config and Eureka, so no config server, discovery server or gateway runs.
Why a patch and not a commit on the branch?
The per-pull-request review is read only and never pushes, so the author keeps the branch. Applying the patch from the review adds the test classes for the next ./mvnw test.