Giter Site home page Giter Site logo

api-web-test-automation-java's Introduction

API and WEB UI Test Automation Framework

stars - api-web-test-automation-java forks - api-web-test-automation-java License issues - api-web-test-automation-java
pages-build-deployment GitHub Actions Workflow Status
View site - GH Pages

  • This framework is built for the purpose of automating API services and WEB applications.
  • This can also be used as a base framework to automate any application that has API and WEB interfaces.
  • However the main intention of this framework is not just to create yet another framework on GitHub,
    but to solve some of the below problems that I feel most of the ones I know of, do not solve
    • It uses a real world application that has meaningful user flows and use cases.
      Thanks to Cypress for open sourcing their RWA ( Real World App) for the community. Copyright (c) 2020 Cypress.io
    • Most frameworks do have all the features that we need but there is lack of "How to Apply" it for a real application.
    • Dummy APIs or Web Apps are used for demonstration lacking detailed user flows and use cases, so that people can relate to it.
    • In real, applications keep changing in different fronts, API, UI ( Web, Mobile ) and
      our Tests within framework must be able to detect changes, this part is missing as to how will our tests behave when there is a change in application itself.
    • Also having access to API for the same Web Application makes it a close to real scenario, where we can leverage good test design strategy.
      Without API access, testing Web application is an anti-pattern.
    • Cypress App solves all above problems, thus is a good fit to be used as AUT ( Application Under Test)

Tech Stack

Programming Language Java
Build and Library management Maven
WEB automation Library Selenium , Selenide
API automation Library Rest Assured
Assertion Library AssertJ
Test runner Library Junit5
CI Github Actions
Optimize boilerplate code Lombok
JSON Parser Jackson
Secret manager git-crypt
Fake Test data generator datafaker
Configuration manager OWNER
Logging logback

Framework features

  • Cross browser automation
  • Page object model for easier management of pages and tests
  • API Automation
  • Fluent Assertion wrappers
  • Environment switching
  • Manage environment specific configurations or framework configurations
  • Test grouping, tagging
  • Parallel execution of tests with auto scaling
  • Generate dynamic test data
  • Logs and Report Dashboard
  • Integration with CI tool like Jenkins/Github actions
  • Secrete management
  • Automatic Code formatting
  • Slack notification (via CI tool)

How to setup ?

  1. Install Java JDK 17 or above
  2. Clone repository: [email protected]:avighub/test-automation-java-restassured-selenide.git
  3. Unlock Secret:
    • git-crypt is used to manage secrets in this framework
    • It needs a secret file to unlock the encrypted files such as properties files that contains credentials and urls of the application
    • In general this secret file should be kept in a secured vault (Not exposed to public) within organization.
    • However since this framework is meant to be publicly accessed, I have added the secret key to git but ,
      in general it should be kept in secured location and to be shared securely
    • Install git-crypt in your system , follow the doc here
    • Once done, run git-crypt unlock git-crypt-secret-public
    • Now you should be able to see configurations file (properties files) contents
  4. Install and setup pre-commit hook locally
    • Install pre-commit package manager
    • Install the git hook scripts in project: pre-commit install
    • That is it, next time you make any commit from local or CI, it will prevent pushing bad formatted code
  5. Run Unit Tests to ensure a sanity check passes: mvn clean test -Dgroups={"UnitTest"}

How to write test?

  • Add relevant meta annotations at test level (Avoid adding at class level as it is easy to miss the annotation)
  • You may use multiple annotations, example :
  • @Test : Mandatory for all tests
    @SkipBeforeEach : Skips running @BeforeEach
    @Login : Login feature tag
    @Sanity : Sanity Test type
    @Flaky : Marks Flaky and disables, add comment to explain
    @Failing: Marks as failing and disables, add comment to explain
    

Best practices

  • Follow meaningful naming standards across the framework
  • Follow naming convention for test
    • Should {do something} if {given a state or performed an action}
  • Make sure to add annotation to each test or test class based on their category
    • Example:
      • Login feature tests , we can mark class with @Login
      • If it is specific to a test we can mark annotation to individual test too
    • To run via commandline mvn clean test -Dgroups=login or mvn clean test -Dgroups={"login","inventory"}
    • Check test/annotations for more meta annotations list
  • Follow commit message format
    • Ask below questions while thinking of meaningful commit message
      • Why have I made these changes?
      • What effect have my changes made?
      • Why was the change needed?
      • What are the changes in reference to?
    Use below prefix for each commit type to follow a standard feat – a new feature is introduced with the changes
    fix – a bug fix has occurred
    chore – changes that do not relate to a fix or feature and don't modify src or test files (for example updating dependencies)
    refactor – refactored code that neither fixes a bug nor adds a feature
    docs – updates to documentation such as a the README or other markdown files
    style – changes that do not affect the meaning of the code, likely related to code formatting such as white-space, missing semi-colons, and so on.
    test – including new or correcting previous tests
    perf – performance improvements
    ci – continuous integration related
    build – changes that affect the build system or external dependencies
    revert – reverts a previous commit

References

Credits

api-web-test-automation-java's People

Contributors

avighub avatar kona-dew avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.