cpp-test-authoring
Skill1 starsChanged 7 months agoMITView on GitHub
Author or extend automated tests in HMCTS CPP test repos. Use when writing a new Serenity BDD/Cucumber UI scenario in cpp-ui-e2e-serenity, or a new JUnit 5 + REST Assured *IT.java in cpp-apitests, or when extending existing features, step definitions, page objects, or integration tests in those repos.
In this repository15 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- api-contract-checkSkill
- architecture-designSkill
- context-scaffoldSkill
- context-service-guideSkill
- dependency-auditSkill
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-exploreSkill
- openspec-proposeSkill
- pipeline-debugSkill
- review-prSkill
- springboot-api-from-templateSkill
- springboot-service-from-templateSkill
- terraform-validateSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Before writing test code:
- Distinctive: line 34
No PII, case data, or court reference numbers in any planned fixture, feature, or assertion (hard rule)
- Distinctive: line 43
If neither marker is present, stop — you're in the wrong repo.
- Very specific: line 70
Step definitions: must extends the page object they exercise.
- Distinctive: line 106
Reuse helpers and builders: before creating new ones — grep for the domain you're testing:
- Distinctive: line 140
When the test is ready:
- Very specific: line 141
Run review-pr against the diff first — it has a section for these two repos
- Distinctive: line 142
If it surfaces blocking issues, fix before raising
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CPP Test Authoring
Guides contributors through the conventions of the two HMCTS Crime Common Platform test repositories so new tests slot into existing patterns instead of forking them.
Repos covered:
cpp-ui-e2e-serenity— UI end-to-end (Serenity BDD 4.x + Cucumber 6 + Selenium, Java 17, Maven)cpp-apitests— API integration tests (JUnit 5 + REST Assured, Java 17, Maven)
When to Use
- User asks to add or extend a UI E2E test, Cucumber feature, step definition, or page object
- User asks to add or extend an API integration test (
*IT.java) - User asks "how do I add a test for X" while inside either repo
- Reviewing whether a proposed test follows the established pattern (defer the actual PR review to
review-pr)
When NOT to Use
- Authoring unit tests inside a runtime service (
cpp-context-*,cpp-mbd-*) — that's part of the service's own conventions - Writing or modifying Spring Boot service code — see
springboot-service-from-template - Pipeline failures — defer to
pipeline-debug - WCAG audits — defer to
accessibility-check
Prerequisites
Before writing test code:
- Story has acceptance criteria — apply
write-acceptance-criteriaif missing - For UI scenarios, the Gherkin draft exists — apply
generate-bdd-specsif missing - Jira ticket is linked (hard rule from
claude/CLAUDE.md) - No PII, case data, or court reference numbers in any planned fixture, feature, or assertion (hard rule)
Step 1 — Identify the Repo and Test Layer
| Repo | Layer | Marker files |
cpp-ui-e2e-serenity | UI E2E | serenity.properties, azure-pipelines-dev01_*.yml, src/test/resources/features/ |
cpp-apitests | API integration | apitests-pipeline.yaml, api-integration-test/ module, *IT.java suffixed tests |
If neither marker is present, stop — you're in the wrong repo.
Step 2 — UI E2E: Authoring a Serenity / Cucumber Test
Directory map
cpp-ui-e2e-serenity/
├── src/test/java/com/
│ ├── pageobjects/ # One class per page/section; holds locators + interactions
│ ├── stepdefinitions/ # Cucumber glue; extends the relevant page object
│ └── runner/ # TestRunner.java, RetryTestRunner.java
├── src/test/resources/
│ ├── features/<domain>/ # *.feature files (Gherkin)
│ ├── locators/custom-locators.json
│ └── testdata/<domain>/
└── serenity.propertiesAuthoring checklist
- Reuse first — grep
stepdefinitions/andpageobjects/for the journey before creating new classes. Duplicating a step definition is the single most common review reject. - Place the feature file under the correct
features/<domain>/folder. Match the naming style of neighbours (CPS,In-Sprint, etc.). - Tag scenarios for the pipeline they belong in. The repo has many runner profiles:
azure-pipelines-dev01_regression.yml— main regressionazure-pipelines-dev01_BPO_regression.yml— BPO regressionazure-pipelines-dev01_migration*.yml— migration suites (vanilla / EDT / nows / ts)azure-pipeline-cdci-dlrm.yml— DLRM Choose tags consistent with the existing features in the same folder.
- Step definitions must
extendsthe page object they exercise. Annotate steps with@Step. Do not hold state in static fields — use the Serenity session. - Page objects own all locator strategy. Register new locators in
src/test/resources/locators/custom-locators.json; do not hard-code selectors in Java. - Wait correctly — use Serenity / WebDriverWait conditions. No
Thread.sleep. - Test data goes under
src/test/resources/testdata/<domain>/. No real names, NI numbers, URNs, or court refs — use the existing fake data pattern. - Wire glue —
TestRunner.javadeclaresglue = "com.stepdefinitions". If you add a new package, update the runner. - Local run —
mvn clean verify -P<profile>. Serenity report lands intarget/site/serenity/index.html.
Common rejects to avoid
- New page object that duplicates locators from an existing one
- Hard-coded XPath in a step definition
Thread.sleep(...)instead of an explicit wait- Feature file in the wrong domain folder so it isn't picked up by the intended pipeline tag
- Real defendant / officer / court data in
testdata/
Step 3 — API: Authoring a *IT.java
Directory map
cpp-apitests/api-integration-test/src/test/
├── java/uk/gov/moj/
│ ├── AbstractTest.java # Root base
│ ├── ApplicationsAbstractTest.java
│ ├── AuditAbstractTest.java
│ ├── AuthorizationAbstractTest.java
│ └── test/ # *IT.java live here
└── resources/<domain>/ # JSON fixtures, payloadsAuthoring checklist
- File naming is load-bearing — must end
IT.java. Failsafe only picks up that suffix;*Test.javawill not run in CI. - Extend the closest abstract base:
- General API →
AbstractTest - Audit assertions →
AuditAbstractTest - Authorization flows →
AuthorizationAbstractTest - Applications API →
ApplicationsAbstractTestThe base wires@ExtendWith(TestHook.class)and shared setup. Do not re-declare hooks.
- General API →
- Reuse helpers and builders before creating new ones — grep for the domain you're testing:
JsonUtil,DbUtil,ApplicationUtil,RestAssuredFileUploadUtil- Domain helpers, e.g.
CpsUnifiedSearchHelper - Builders, e.g.
CpsCaseIngestionData.Builder
- REST Assured pattern — use
given().when().then()with Hamcrest matchers or AssertJ. Avoid rawassertEqualson JSON paths. - Fixtures live under
src/test/resources/<domain>/. Load viaJsonUtil. No PII / court refs. - Contract alignment — when asserting a response shape, cross-check it against the producing service's RAML / OpenAPI. Apply
api-contract-checkif the response surface is changing. - Local run —
mvn clean verify(Failsafe phase). Single class:mvn verify -Dit.test=MyEndpointIT -pl api-integration-test.
Common rejects to avoid
- File named
*Test.java(Failsafe skips it) - Extending
AbstractTestwhen a more specific base exists - Inline JSON payload strings instead of resource fixtures +
JsonUtil - New helper class that duplicates an existing util
- Hard-coded bearer tokens or URLs — use the configured environment
Step 4 — Pre-Commit Checklist (both repos)
- No PII / case data / court reference numbers anywhere in the diff
- Existing page objects / step defs / helpers / builders were reused, not duplicated — apply
simplifyif unsure - (UI only) Journey passes a11y check — apply
accessibility-check - (API only) Assertions match the producing service's contract — apply
api-contract-check - ADR raised for any deviation from the patterns above — apply
adr-template - Test runs green locally
- Test runs green on the targeted pipeline profile
Step 5 — When CI Fails
Defer to pipeline-debug. Identify the failing YAML first:
- UI: one of the
azure-pipelines*.ymlvariants incpp-ui-e2e-serenity - API:
apitests-pipeline.yamlorazure-pipelines.yamlincpp-apitests
Step 6 — Raising the PR
When the test is ready:
- Run
review-pragainst the diff first — it has a section for these two repos - If it surfaces blocking issues, fix before raising
- Open the PR; reviewer runs
review-pragain as part of the merge gate
Related Skills
write-acceptance-criteria— derive ACs from the story (run first)generate-bdd-specs— author the Gherkin feature (UI only)accessibility-check— WCAG 2.1 AA on user-facing journeysapi-contract-check— RAML / OpenAPI alignment for*IT.javareview-pr— PR review checklist (includes a test-repo section)pipeline-debug— CI failure diagnosissimplify— reuse and dedupe pass before commitadr-template— record any deviation from the patterns abovesecurity-review— required if touching auth, session, tokens, or PII handling
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

