Code Monkey home page Code Monkey logo

offline-execution-engine's Introduction

offline-execution-engine

Data driven testing framework

Example of a restful request

This is an example test data which means to request youtub

  • Json test data
  • Assert with copy from http json response
  • Support regex in assertion
  {
    "name": "POC GET",
    "workflow": "APITest",
    "assets": [
      {
        "info": "---this is a demo for requesting YouTube restful api---",
        "request": {
          "method": "GET",
          "url": "https://www.googleapis.com/youtube/v3/search",
          "param": {
            "part": "snippet",
            "q": "ExecutionEngine+Cactus",
            "type": "video",
            "key": "AIzaSyBXpFaKcdrc3N70wxmO1Qj6tszmbaoR-GU"
          }
        },
        "assertions": {
          "StatusCode": 200,
          "ResponseJson": {
            "kind": "youtube#searchListResponse",
            "etag": "\"[\\s\\S]+\"",
            "regionCode": "TW",
            "pageInfo": {
              "totalResults": 0,
              "resultsPerPage": 5
            }
          }
        }
      }
    ]
  }

Example of a loop request

Send request twice

  {
    "name": "POC GET",
    "workflow": "APITest",
    "assets": [
      {
        "repeat": 2,
        "assets": [
          {
            "info": "---this is a demo for requesting YouTube restful api---",
            "request": {
              "method": "GET",
              "url": "https://www.googleapis.com/youtube/v3/search",
              "param": {
                "part": "snippet",
                "q": "ExecutionEngine+Cactus",
                "type": "video",
                "key": "AIzaSyBXpFaKcdrc3N70wxmO1Qj6tszmbaoR-GU"
              }
            }
          }
        ]
      }
    ]
  }

Example of extracion from response

Use "extracion" key to extract value from response, and use in next test. Any formated string as "{{key}}" will be replace with the value from extractions.

  {
    "name": "POC GET",
    "workflow": "APITest",
    "assets": [
      {
        "info": "---this is a demo for requesting YouTube restful api---",
        "request": {
          "method": "GET",
          "url": "https://www.googleapis.com/youtube/v3/search",
          "param": {
            "part": "snippet",
            "q": "ExecutionEngine+Cactus",
            "type": "video",
            "key": "AIzaSyBXpFaKcdrc3N70wxmO1Qj6tszmbaoR-GU"
          }
        },
        "extractions": {
          "etag": "etag"
        }
      },
      {
        "info": "---this is a demo for requesting YouTube restful api---",
        "request": {
          "method": "GET",
          "url": "https://www.googleapis.com/youtube/v3/search",
          "param": {
            "fakePram": "{{etag}}",
            "part": "snippet",
            "q": "ExecutionEngine+Cactus",
            "type": "video",
            "key": "AIzaSyBXpFaKcdrc3N70wxmO1Qj6tszmbaoR-GU"
          }
        }
      }
    ]
  }

Example of JavaScript injection

Java script can be inject with format "[js[ 1 + 1 ]]", and can be used to assert a field in response, print something, or even sleep seconds. Combine with extraion feature will be a good pratice.

      "assertions": {
          "StatusCode": 200,
          "ResponseJson": {
            "success": true,
            "message": "[js[print('delay for send gift');for(var t = Date.now();Date.now() - t <= 5000;);'']]",
            "error_code": 0,
            "results": {
              "diamond": "[js[ {{myDiamond}}-{{giftCost}} ]]",
              "usableBalance": {
                "userId": "{{userIdA}}",
                "diamond": "{{myBalance}}"
              }
            }
          }
        }

Example of DB operation -- NoSql mongo

{
    "name": "MongoFindOne",
    "workflow": "APITest",
    "assets": [
      {
        "info": "---Mongo Find---",
        "mongoOperation": {
          "query": {
            "table": "hostapplication",
            "criteria": {
              "userId": 5
            }
          }
        }
      }
    ]
  }

Example of DB opration -- Cache DB Redis

_id will be transfer as DBObject

  {
    "name": "RedisGet",
    "workflow": "APITest",
    "assets": [
      {
        "info": "---POC for redis get---",
        "redisOperation": {
          "get": {
            "criteria": {
              "_id": "f34rgju789iuhgfd32wsxcfg",
              "try": "null"
            }
          }
        },
        "assertions": {
          "ResponseString": "[\\w]+"
        }
      }
    ]
  }

Example of DB operation -- Sql Postgres

  "SqlOperation": {
    "select": {
      "table": "user",
      "criteria": {
        "id": 1,
        "name": "leo"
      }
    }
  }

api-test

framework for rest api testing

carnival

worker repository

engine-core

implementation of executeion engine

engine-data

implemnttation of main bean for execution engine (TestData), extend TestData class to customize testing behavior

testng-base

offline execution solution, testNG based, extend AbstractMainTest to customize execution behavior

web-application

online execution solution, spingboot + mongo, still under developing

offline-execution-engine's People

Contributors

leozlzhang avatar

Stargazers

yanhaizhe avatar  avatar Edison avatar

Watchers

James Cloos avatar  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.