sumo-api-automation

2.0.13 • Public • Published

sumo-api-automation

A package to automate the integation testing requiring minimal coding and setup.

Installation

Install sumo-api-automation package with npm globally, run with sudo if access denied

  npm install -g sumo-api-automation

After installation, "sumotest" command will be available in your terminal to use.

Usage

sumotest init <some_path>

This will initialize a sample demo app and sample tests in the <some_path> directory.

If no path is passed, then it will be initialized in the current directory.

Running demo-app and sample-tests

  • Inside demo-app, install npm packages and run it
  cd demo_app
  npm install
  npm run start
  • In order to run the test cases run below command from another terminal window.
  sumotest run <path_where_tests_repo_clonned>

e.g.

  sumotest run ~/Documents/sumotestdemo/sample_tests
  • For generating test cases and env variables postman collection files, run below command to get the json files that can be imported in postman
  sumotest export -tr <path_where_tests_repo_clonned> -tdr <target_path>

e.g.

  sumotest export -tr ~/Documents/sumotestdemo/sample_tests -tdr ~/Documents/sumotestdemo/

Documentation

Prereq:- install node version 14 or above

How to use:-
1. make your entries in .env file
2. create directory with proper test name
3.create following files
    config.json (for api , expected status , type (get, post,put), context management)
    headers.json (for your rest api headers)
    request.json (for request body json)
    response.json (expected response)
4. run npm test
5. It will do a deep assert and present the result

Running integration tests in the DEV environment

kubectl port-forward -n dal-msk service/elasticsearch 9200:9200 &
API_BASE_PATH="SET YOUR PATH HERE" npm test
Single Test Execution
1. make sure TEST_NAME= "" in .env
2. run npm test , It will create and persist Context
3. set your test name TEST_NAME= "002_login_super_admin,001_Test" in .env
4. now run npm test , it will use previous context


```Features
1. Local Context

 {{RANDOM_EMAIL}} , {{RANDOM_NAME}},{{RANDOM_GUID}}
  --Use above anywhere , url , headers, request, response
  for multiple you can use like
  {{RANDOM_EMAIL1}} , {{RANDOM_NAME1}},{{RANDOM_GUID1}}
  {{RANDOM_EMAIL2}} , {{RANDOM_NAME2}},{{RANDOM_GUID2}}

2. Global Context (BDD)
   --in cofig-->responseConfig set values in gloabal conext like below

        "context_actions":[{"type":"set","to_key":"userId","from_key":"userId","scope":"global"}

   --in any subsiquent  request use like below in anywhere , url , headers, request, response

        {{__global_context.userId}}

3.How to debug
  For every test execution (pass , failed , errored), there is log file with name output.log
  Check this file for testing data

4.responseConfig
  This is most imporant featuer to understand
  -- Once response is recived it tells what needs to be done with it
  -- if you want to check Id is generated use like below

         "idField":"merchantId",
        "checkIdGeneration":true,

  --There always be some fields in response which you don't want to validate
    for this set following

         "skipFieldsInDeepAssert":["merchantId"],

  --For DeepAssertions set following

          "deepAssert":true,

Added "doNotValidateResponse":true in config. If this is set, no response will be validated, status will also not be validated. This is used to mostly create master data

added skip:true, in config.json. incase we want to skip that test case

Readme

Keywords

none

Package Sidebar

Install

npm i sumo-api-automation

Weekly Downloads

2

Version

2.0.13

License

Apache-2.0

Unpacked Size

49.8 kB

Total Files

14

Last publish

Collaborators

  • ritesh.agarwal_tal