GithubHelp home page GithubHelp logo

ssreejithmails / pandaria Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jakimli/pandaria

0.0 1.0 0.0 6.68 MB

Lightweight API testing tool based on cucumber JVM

License: MIT License

Java 77.37% Gherkin 21.78% JavaScript 0.03% TSQL 0.82%

pandaria's Introduction

Pandaria

Lightweight API testing tool based on cucumber JVM

Build Status Maven Central

Introduction

Pandaria is a DSL written based on cucumber JVM to simplify the HTTP/Graphql API testing, everything with cucumber still works. Using pandaria you don't need to learn programming

中文介绍

Example

You can call your api and verify the response

* uri: http://localhost:10080/users/me
* send: GET
* status: 200
* verify: '$.username'='jakim'
* verify: '$.age'=18

And you can query database and verify the results

* query:
"""
SELECT NAME, AGE FROM USERS
"""
* verify: '$[0].name'='jakim'
* verify: '$[0].age'=18

Or like this:

* query: select.sql
* verify: '$[0].name'='jakim'
* verify: '$[0].age'=18

Mongo DB also supported

And you can wait until the verification passed:

* wait: 1000ms times: 3
* uri: /sequence
* send: GET
* response body:
"""
3
"""

Above code send GET to /sequence and expect response body equals 3, if not it will sleep 1000ms and then retry, until it succeded passing or exceeds max 3 times and fail. same with database query.

* wait: 1000ms times: 3
* query: select.sql
* verify: '$[0].name'='jakim'
* verify: '$[0].age'=18

You can also verify JSON schema:

* uri: /products/1
* send: get
* verify: '$' conform to:
"""
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://example.com/product.schema.json",
"title": "Product",
"description": "A product in the catalog",
"type": "object"
}
"""

* verify: '$' conform to: schema/product.schema.json

More Usage

Resources

Latest Release

  • 0.3.1

See Release Notes

Get Started

If you don't need to verify database mongo, or graphql, just remove the pandaria-db, pandaria-mongo or pandaria-graphql from dependency declarations.

Gradle

dependencies {
    testCompile(
            "io.cucumber:cucumber-junit:4.0.0",
            'com.github.jakimli.pandaria:pandaria-core:0.3.1',
            'com.github.jakimli.pandaria:pandaria-db:0.3.1',
            'com.github.jakimli.pandaria:pandaria-mongo:0.3.1',
            'com.github.jakimli.pandaria:pandaria-graphql:0.3.1'
    )
}

Maven

<dependencies>
  <dependency>
    <groupId>com.github.jakimli.pandaria</groupId>
    <artifactId>pandaria-core</artifactId>
    <version>0.3.1</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>com.github.jakimli.pandaria</groupId>
    <artifactId>pandaria-db</artifactId>
    <version>0.3.1</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>com.github.jakimli.pandaria</groupId>
    <artifactId>pandaria-mongo</artifactId>
    <version>0.3.1</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>com.github.jakimli.pandaria</groupId>
    <artifactId>pandaria-graphql</artifactId>
    <version>0.3.1</version>
    <scope>test</scope>
  </dependency>
</dependencies>

If you need to verify database, remember to add specific jdbc driver for your database to build.gradle or pom.xml, and add you datasource connection in application.properties

application.properties

spring.datasource.url=jdbc:mysql://localhost:3307/pandaria?useSSL=false&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=password
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

If you need to interact with mongo db, also add:

mongo.db.name=test
mongo.db.connection=mongodb://root:password@localhost:27017

If you're using JUnit, you might want to add below:

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {
        "pretty",
        "junit:build/cucumber-reports/cucumber.xml",
        "json:build/cucumber-reports/cucumber.json",
        "html:build/cucumber-reports",
},
        features = "classpath:features/",
        glue = {"com.github.jakimli.pandaria"},
        tags = "not @ignore")
public class RunCucumberTest {
}

Make sure com.github.jakimli.pandaria is in the list of cucumber glue.

Above code also configures reports for junit, json and html. also it excludes all features that marks as @ignore from execution. You can ajust this according to your requirement.

Then you can start to write your first automation test.

Feature: hello world
  This is the first feature for pandaria

  Scenario: hello world
    * uri: https://github.com
    * send: GET
    * status: 200

pandaria's People

Contributors

jakimli avatar meixuesong avatar

Watchers

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