Code Monkey home page Code Monkey logo

apitest's Introduction

apitest: RESTful APIs testing command. BDD-like, blackbox, automated testing with containers or CIs

  • API testing command for containers and CIs.
  • Simplest, Fastest, Smallest API test tool.
  • BDD like YAML Testing format: Readable and Writable.
  • Smallest docker image (It will be about 10MB)
  • JSON Format support.
  • Mock support(developping)
  • IT only supports single repo testing.
  • Other servers are all mocks.

Build Status

Purpose: Why I develop apitest?

  • I want to use Automatic Sequential API Testing Tool in docker or CI.
  • I can't find any docker friendly API Testing tools.
  • I don't need GUI, I don't need multifunctional testing.

So I develop apitest, which is small, docker friendly and minimum.

Why and When you use apitest?

  • When you develop an API server, try apitest with CI.
  • apitest provides your development automatic continuous testing.
  • It brings you more safety and faster development.

apitest vs other API Testing tools or framework.

  • Testing Frameworks with GUI: apitest is a minimal simple command for CI.
  • Karate: Karate is great tool so apitest is sub-choise when you want to do minimum test in CI.
  • Manual Testing: apitest has Repeatablity and doesn't have human errors.

Example of yaml file

Feature: Sample Yaml

Scenarios:
  - Scenario: Normal
    description: Normal
    Given:
      host: http://server:8080
    Tests:
      - When:
          method: GET
          path: /api
        Then:
          status: 200
          format: "empty"
      - When:
          path: "/api/users/"
          method: POST
          body: '{"Token": "Foo", "Name": "Foo"}'
        Then:
          status: 200
          format: application/json
          require:
            - 'match {"name": "Foo", "Info": "#String"}'
      - When:
          path: /api/users/
          method: POST
          body: '{"Token": "Foo"}'
        Then:
          status: 200
          format: application/json
          require:
            - 'match {"users": "#Array"}'
  

DEMO

please run test.sh.

Install

  • using locally
  • using in docker

Requirements: Go 1.12.x

go get -u github.com/aimof/apitest/cmd/apitest
# workdir: $GOPATH/src/github.com/aimof/cmd/apitest
go install

Using in docker

See cmd/apitest/README.md

Usage

apitest /path/to/test.yaml

Request body and Response body

  • Only Json support.

Types

NumberType = "#Number"
StringType = "#String"
BoolType   = "#Bool"
ObjectType = "#Object"
ArrayType  = "#Array"
NullType   = "#Null"

Testing

# in the repository root
go test ./...
./test.sh

PLAN

  1. Change YAML Format to BDD like Style (Destructive change): Done
  2. Make Docker Image: Trial is done.
  3. Support Single Mock (Destructive change)
  4. Support Multiple Mock (Destructive change)

Contribution

Please feel free to make Issues or PRs but I will plan some destructive changes.

LICENSE

MIT

apitest's People

Contributors

aimof avatar

Stargazers

 avatar  avatar

Watchers

 avatar

apitest's Issues

Reference to Karate in the documentation

In the README you mention:

Karate: Karate is a good tool but it run on JVM. Karate is not container friendly.

Actually Karate has a 25 MB executable and only the JRE is needed as a pre-requisite.

If you see this thread - many people have been able to run Karate in Docker: karatelabs/karate#396

Can you explain what you mean when you say Karate is not container friendly ? ?

Dose this tool have a relation of docker-component version?

When I use test.sh in Ubuntu 18.04, there is a following error.

  • Install docker-compose by apt command (I'm sorry to forget checking version).
$ ./test.sh
ERROR: Version in "././test/docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

And I can run test.sh after updating dockrer-compose as following:

sudo apt remove docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

(Refer;https://stackoverflow.com/questions/42139982/version-in-docker-compose-yml-is-unsupported-you-might-be-seeing-this-error)

So, this tool need some minimum version of docker-component. Doesn't it?

Scenarioテストでは、複数のエンドポイントを利用することは想定しないのですか?

yamlの定義としては1つなので1シナリオに対して1つのホストを指定する形に見えました。
そうなった場合、基本的にはこれで十分だと思うのですが、複数のサービスに跨って利用されるAPIの場合にどうテストするのでしょうか?

例えば認証前提のサービスAに対するAPIで、その認証情報はサービスBに対して登録されたものを使う場合、

  1. サービスBに認証情報を登録して、
  2. サービスAにアクセス

といった複数サービスを利用した試験をしたくなると思います。
こういった試験はカバーする設定があるのか、シナリオの定義でカバーするのか、そもそも対象外なのかが気になりました。

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.