Search This Blog

Thursday, September 2, 2021

API Automation Guidelines

 As an automation engineer, we need to follow a few guidelines.

Few of the guidelines as below:

  • No code change in the master branch directly - work on feature branches

  • Build the project locally before raising a PR

  • Run the test(s) locally before raising a PR

  • There has to be at least 1 person who reviews a PR

    • Post your PR link on the slack channel tagging concerned people and the reviewer would merge the PR and update with a comment on the slack thread

    • Reviewer has to ensure that the newly added tests are passing on the pipeline before merging

  • Ensure we add proper commit message while committing any code

    • Example: “automated customer cancel in order flow” or “modified X to achieve Y“. Basically meaningful commit instead of just writing “commit“ “fixed“ etc

  • Test Method should be 40-50 lines long at max

    • Break it into private methods if needed

    • Name the test method such that there is NO need of documenting its behaviour - test method names should start with "verify******"

  • Do NOT span any PR beyond 3-4 days - either get it merged within this time period or close the current one (if it is spilling over 3-4 days) and create another after local rebase

  • Put all assertions in Test classes (use return in helper methods to get what needs to be compared for assertions)

  • Always add a message with assertions to be logged upon a failure - it gives the good context of the issue in the report upon a failure, upfront

  • Ensure the correct tags are attached to the scenarios/tests before raising a PR (Smoke, Regression, ServiceType)

  • Don’t use “System.out.println” in the code, use TestNG logger only.

  • Add allure annotations properly so test reports can be used effectively.

  • Test your code with all negative cases. Avoid null pointer exceptions in your code.

  • Add logging for each api call (Request Call/Request Payload/Response Json are the minimal ones).

  • Add all other necessary logging for your test case so it can be helpful later for the debugging

  • Avoid adding redundant code and create a helper method instead.

  • Always add health check verification for the new APIs.

No comments:

My Profile

My photo
can be reached at 09916017317