当前位置: 首页 > 软件库 > 大数据 > 数据查询 >

just-api

💥 Test REST, GraphQL APIs
授权协议 MIT License
开发语言 Java
所属分类 大数据、 数据查询
软件类型 开源软件
地区 不详
投 递 者 杜禄
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Just-API

Just-API is a declarative, specification based test framework for REST, GraphQL APIs. Users can test APIs without writing code, but they can also tap into code when they want to. It reads API test specification from YAML files and runs them in serial/parallel mode. Test reports can be generated in several formats including HTML and JSON.

In simple terms, users build a test suite by providing a set of request and response validation specification in a YAML file. Each suite can have one or more specs. Just-API builds the request, sends it to server and validates response as per the specification.One can choose to validate any or all of following

  • Status code
  • Headers
  • Cookies
  • Response JSON body
  • Response JSON schema

or Provide a custom Javascript function to validate the response

Find more here

Links

Features

  • Runs test suites in parallel/serial mode
  • Supports all widely used HTTP methods
  • Supports x-www-form-urlencoded requests, Multipart requests, File uploads
  • Built-in Response Validation Constructs(Headers, Cookies, Status code, JSON body, JSON schema)
  • Custom Response validator functions
  • Supports running custom inline or module javascript sync/async functions
  • Supports Hooks (Before All, After All, Before Each, After Each, Before Test, After Test)
  • Custom suite configuration
  • Chained Request flows
  • Define/override Request path, query params, path params, headers, body at runtime
  • Suite and test context for reuse
  • Supports importing specs from one or more test suites
  • Intrasuite and Intersuite spec dependencies
  • Reusing test specification
  • Retry failed tests
  • Looping: Generate 'n' number of tests with a list
  • Built-in HTML, JSON reporters
  • Can generate reports in multiple formats for the same run
  • Logging HTTP request/response data for failed tests
  • Proper error reporting
  • Can run tests matching with a given pattern/string
  • Skipping tests with specification
  • Disable or Enable redirections
  • Reports test duration
  • Allows user to plug-in custom reporters

See all features

Getting Started

To run just-api, you will need Node.js v10.x.x or newer.

Installation

$ npm install just-api

Following is a simple example showing usage of Just-API.

$ mkdir specs
$ vim specs/starwars_service.yml

Write following suite in your editor

meta:
  name: Star Wars suite
configuration:
  scheme: https
  host: swapi.co
  base_path: /api
specs:
  - name: get Luke Skywalker info
    request:
      path: /people/1/
      method: get
    response:
      status_code: 200
      headers:
        - name: content-type
          value: !!js/regexp application/json     
      json_data:
        - path: $.name
          value: Luke Skywalker

Back in the terminal

$ ./node_modules/.bin/just-api

   ✓ get Luke Skywalker info (1216ms)

  Done: specs/starwars_service.yml (Passed)

0 skipped, 0 failed, 1 passed (1 tests)
0 skipped, 0 failed, 1 passed (1 suites)
Duration: 1.3s

Testing GraphQL APIs

Following example tests a GraphQL API that returns Person info for a given name.

Create a YAML suite and run just-api.

meta:
  name: GraphQL Starwars service
configuration:
  host: swapi.graph.cool
  scheme: https
specs:
  - name: Get Details of a character
    request:
      method: post
      headers:
        - name: content-type
          value: application/json
      payload:
        body:
          type: json
          content:
            query: >
                   {
                    Person(name: "Luke Skywalker") {
                      name,
                      id,
                      gender
                     }
                    }
            variables: null
            operationName: null
    response:
      status_code: 200
      json_data:
        - path: $.data.Person.name
          value: "Luke Skywalker"

A chained request flow with hook and custom validation

When you need to test complex chained API flows, run dependencies in hooks to fetch pre-requisite dataand pass it to actual test.

Following example shows how to run dependencies using a hook, get data and validating response with a custom validator function.

meta:
  name: Starwars suite
configuration:
  scheme: https
  host: swapi.co
  base_path: /api
specs:
  - name: get R2-D2 info
    request:
      path: /people/3/
      method: get
    response:
      status_code: 200
      json_data:
        - path: $.name
          value: R2-D2

  - name: search R2-D2 info
    before_test:
      run_type: inline
      inline:
        function: !js/asyncFunction >
          async function() {
            var response = await this.runSpec('get R2-D2 info');
            var jsonData = JSON.parse(response.body);
            this.test.query_params = { name:  jsonData.name };
          }
    request:
      path: /people
      method: get
    response:
      status_code: 200
      custom_validator:
        run_type: inline
        inline:
          function: !!js/function >
            function() {
              var jsonData = JSON.parse(this.response.body);
              var r2d2 = jsonData.results.find(result => result.name === 'R2-D2');

              if (!r2d2)
                throw new Error('R2-D2 not returned in search results');
            }

Note: You can also place custom JS functions in a module and specify the function name, module path in YAML to import.

More advanced stuff can be done with Just-API. Documentation says it all.Take a look at Just-API Website for detailed documentation.

If you are looking to use Docker to run Just-API, you might want to checkoutJust-API docker boilerplate here

Maintainer

Kiran kiran.6d.hex@gmail.com

License

MIT-licensed

References

Donation

If this project helps you in anyway, Please consider making a donation

Contributing

NOTE: recommend Node v10.x since v12.x has gulp compatibility issue.

  1. Install deps npm install
  2. Install gulp npm install -g gulp
  3. Install test files gulp
  4. Install test API npm run install_testapi
  5. Run test API npm run start_testapi
  6. (in a new window) npm test

Test Structure

  • test/cli/src/suites/[suite].spec.yaml contains sample suites/specs
  • test/cli/[suite].spec.js contains JS chai/mocha test assertions about the sample suite/specs

You may need to create/modify both a sample suite/spec and corresponding JS assertion

Code Quality & Formatting

TODO: add linter/hinter/prettier or whatever spec is used

  • overpass-api和overpass-turbo安装 介绍 overpass-api安装 overpass-turbo安装 问题记录 #介绍# overpass-api用于查询openstreemap的node,way和area,官网的overpass-api访问较慢,所以选择装在自己电脑上,安装需要的存储空间比较大,最少几十G。 #overpass-api安装# 安装步骤参考官网http:

  • Maven显示错误: Missing artifact org.just.api:org-just-api:jar:1.9.3 pom.xml 。 The container ‘Maven Dependencies’ references non existing library 解决方法: 1.下载 org-just-api-1.9.3.jar,链接:https://pan.baidu.com/

  • 运行shell脚本时,mv/cp时出现如下提示: mv: will not overwrite just-created <filename> with <sameFilename> cp: will not overwrite just-created <filename> with <sameFilename> 这种现象发生的原因是:移动或复制两个或多个文件名相同的文件到同一个目录下。 这只

  • API:应用程序编程接口 Java API: JDK中提供各种功能的java类,这些类将底层的实现封装了起来,我们不需要关心这些类是如何实现的,只需要学习如何使用这些类即可,我们可以通过帮助文档来学习这些API如何使用

  • 该站免费提供api,欢迎各位使用,如有其他免费的,好用的api,欢迎留言。 进站:点击进入(已失效)

  • 免费的api接口 ,小说api, 视频api,漫画api http://api.pingcc.cn api文档:https://easydoc.net/doc/45910076

  • 根据索引、类型和ID获取文档 GET twitter/_doc/1 返回结果如下: { "_index": "twitter", "_type": "_doc", "_id": "1", "_version": 1, "found": true, "_source": { "user": "kimchy", "post_date": "2009-11-15T

  • 什么是API?为什么要提供API?   API是系统的基石,是Windows的一砖一瓦。 明确一个概念,软件是运行在系统平台的支持上的,软件的功能其实就是向系统申请,并由系统完成这些功能的过程。 那么软件要做的事情如何传递给系统呢,也就是这些API的作用了,系统定义了这些API函数,做为支持软件执行系统功能的接口。 不同的操作系统自然API会是不同的.   API(Application Prog

  • Web API 和 API 有什么区别? API 叫做 应用程序编程接口 就是一种工具。Web API 是浏览器 提供的 浏览器功能 和 页面元素 的 PAI  页面交互功能 ,Web API 一般都有 输入 和 输出 函数的传输 和 返回值。 什么是 DOM 和 BOM呢? DOM :页面文档对象模型 BOM :浏览器对象模型

  • Options API ( 选项API): 咱们在vue2.x项目中使用的就是 选项API 写法 代码风格:data选项写数据,methods选项写函数...,一个功能逻辑的代码分散。 优点:易于学习和使用,写代码的位置已经约定好 缺点:代码组织性差,相似的逻辑代码不便于复用,逻辑复杂代码多了不好阅读。 补充:虽然提供mixins用来封装逻辑,但是出现数据函数覆盖的概率很大,不好维护。

  • W3Cschool JavaScript API 速查词典 - 速查 W3school JavaScript 参考手册 Mozilla 开发社区版:JavaScript 参考手册——中文、英文 常用英语 document 文档 referrer 推荐人,来历,来路。 location

  •  Welcome to my blog! <script language="javascript" src="http://avss.b15.cnwg.cn/count/count.asp"></script> Just let me get my breath, Missis, and Ill start fair. Study While Read : (Windows API Declar

 相关资料
  • just 创建 Observable 发出唯一的一个元素 just 操作符将某一个元素转换为 Observable。 演示 一个序列只有唯一的元素 0: let id = Observable.just(0) 它相当于: let id = Observable<Int>.create { observer in observer.onNext(0) observer.onComp

  • 描述 (Description) Framework7只允许使用带有表单元素的输入字段。 例子 (Example) 以下示例演示了Framework7中仅使用输入 - <!DOCTYPE html> <html> <head> <meta name = "viewport" content = "width = device-width, initial-scale = 1,

  • Just Perfection 是一个用于 Gnome Shell 的扩展。Just Perfection 包括一个选项列表,用于切换 GNOME UI 元素的可见性、自定义面板大小、填充和更改行为。 具备的功能包括: 覆盖 Gnome Shell 主题以创建最小的桌面 隐藏顶栏 在概览屏幕中隐藏顶部栏 删除左上角的“活动”按钮 禁用 app-menu、clock、系统托盘菜单 在概览中删除所选应

  • jorm (Just ORM) 是一个超轻量级的 Java 的对象映射框架。 主要特性: 对象关系映射 自动主键生成 支持 Hibernate 支持附加的 SQL 语句和扩展子查询 支持乐观锁 提供丰富的SQL语句工具 示例代码:     public void load() {         Person person = jormFace.loadEntity(Person.class, 1

  • Just the Class Just the Class is a GitHub Pages template developed for the purpose of quickly deploying course websites. In addition to serving plain web pages and files, it provides a boilerplate for

  • Please note that this this project is no longer maintained Android Sample app with MVP architecture Sample project that displays some images from the dribble API.Demonstrates some cool stuff that you