Giter Club home page Giter Club logo

s2test's Introduction

s2test: A Simple Smoke Test Tool

Intentions

  • To make smoke tests of API easier and more enjoyable for server-side developers

Features

  • Planing smoke tests by using a JSON style config file
    • Various cookies for test can be prepared
  • Reusable test target API information store

Installation

Preparation

Please download and install golang

Clone from Github

$ git clone https://github.com/willsmile/s2test
$ cd s2test

Get the go dependencies (by go modules):

$ GO111MODULE=on go get -v -d

Build the tool

$ go build -o s2test .
$ ./s2test help

Setup and configuration

Test plan preparation

To prepare a test plan by using the following format (for example, let's name the file 'plan.json').

{
  "goal": "Have a try on s2test",
  "endpoints": "./api.json",
  "ua": "tester",
  "auths": {
    "cookieA": {
      "type": "Cookie",
      "name": "cookieName",
      "value": "cookieValue"
    },
    "tokenA": {
      "type": "OAuth 2.0",
      "prefix": "Bearer",
      "value": "tokenValue"
    }
  },
  "tasks": [
    {
      "targetAPI": "GET a sample post",
      "auth": ["tokenA"]
    },
    {
      "targetAPI": "POST a sample post",
      "auth": ["tokenA"],
      "variables": {
        "sample_use_id": "1",
        "sample_post_title": "sample post title"
      }
    }
  ]
}

Also, to write down the information of test target API by using the following format.

{
  "GET a sample post": {
    "description": "GET a sample post",
    "url": "https://jsonplaceholder.typicode.com/posts/1",
    "method": "GET",
    "headers": {
      "Content-type": "application/json; charset=utf-8"
    }
  },
  "POST a sample post": {
    "description": "POST a sample post",
    "url": "https://jsonplaceholder.typicode.com/posts",
    "method": "POST",
    "headers": {
      "Content-type": "application/json; charset=utf-8"
    },
    "body": {
      "title": "#{sample_post_title}",
      "body": "sample post body",
      "userId": "#{sample_use_id}"
    }
  }
}

Test Plan Execution

  • Run with both plan path and api path
./s2test -p plan.json -a api.json
  • Run with only plan path (api path will be set with the value of endpoints in test plan file)
./s2test -p plan.json

s2test's People

Contributors

willsmile avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

heyi89

s2test's Issues

Duplicate code in load

The following function have similar processes.

// LoadPlan uses for loading a test plan from a JSON file
func LoadPlan(path string) Plan {
	var plan Plan

	raw, error := ioutil.ReadFile(path)
	if error != nil {
		log.Fatal("[File Loading Error] ", error)
		os.Exit(1)
	}

	json.Unmarshal(raw, &plan)

	return plan
}

// LoadAPIStore uses for loading APIStore from a JSON file
func LoadAPIStore(path string) APIStore {
	var store APIStore

	raw, error := ioutil.ReadFile(path)
	if error != nil {
		log.Fatal("[File Loading Error] ", error)
		os.Exit(1)
	}

	json.Unmarshal(raw, &store)

	return store
}

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.