Standard Java Code convention is used as basis.
Important: We have to cover actions for controllers with API tests - NOT user flow replicating business logic.
| Module | Goal | Naming/Explanation | Comments |
|---|---|---|---|
| Test Class | Main class used to reflect verification for a Feature | A name of a controller + Test | Example: class MissedAppointmentTest |
| Test Method | Endpoint response validation | verify + action | Example: In the class MissedAppointment they are: • verifyListSortedByName()• verifyShowFilterByLocation()• verifyUpdateRightAllowed()• verifyUpdateNoAccess<Description>()• verifyUpdateAccess<Description>()• verifyDeleteAction()In case there are two equal actions for the same controller add additional "marker" after "Action" word, e.g.: • verifyListActionAdd1• verifyListActionAdd2 |
| Before Method | Precondition to start test | public void executePreconditions() | Create all required entities. For example, for testing Procedure, create Provider and Patient |
| After Method | Postcondition to clean data | public void executePostconditions() | Delete entities created with a test. Set Location setting to a default. |
| Assertions | Verify response with expected data | Method body() of ValidatableResponseOptions class | See example below |
| Utility Class | Common methods which wrap set of rest-assured methods | — | — |
| DTO Class | Depict Json objects sent and received during test execution | Create two classes for each business entity: for create (post) and from response for update (put). | Examples: PatientCreate, PatientUpdate, PaymentDistributionResponse |
| Configuration | Files containing info about app urls, db urls, 3rd parties urls etc. | .env | — |
| Suite for local test run | TestNG xml contains test classes for run | File should be placed in "java" package and name starts from "suite". | Example: suite-ahyre.xml |
| Packaging | Should correspond packaging of ascend source code | package com.henryschein.onlinepm.clinical | — |
Example using the body() method of ValidatableResponseOptions class:
baseRequestSpecification
.when()
.pathParam("patientId", patientId)
.get(PROCEDURE + procedureId)
.then()
.log().all()
.body("amount", is(100.0F))
.body("practiceProcedure.id", isA(Long.class))
.body("xfer.primaryInsurance", is(100.0F));Test Class Structure: Test class should contain only test methods which are related to actions for a specific controller (test class has the controller's name).
Focus on API Actions: Cover controller actions with API tests, not user flow business logic.
Consistent Naming: Follow the naming conventions for test classes and methods to maintain consistency across the test suite.
Data Cleanup: Always implement postconditions to clean up test data and restore default settings.
DTO Separation: Maintain separate DTO classes for create operations (POST) and update operations (PUT) to clearly distinguish between request and response structures.