All Projects → lwfwind → smart-api-framework

lwfwind / smart-api-framework

Licence: Apache-2.0 license
smart api automation framework to support web service api automaton test based on testng and httpclient

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to smart-api-framework

Httpclient Interception
A .NET Standard library for intercepting server-side HTTP dependencies
Stars: ✭ 108 (+620%)
Mutual labels:  httpclient
Curlsharp
CurlSharp - .Net binding and object-oriented wrapper for libcurl.
Stars: ✭ 153 (+920%)
Mutual labels:  httpclient
Httpclient Android
HttpClient repackaged for Android
Stars: ✭ 211 (+1306.67%)
Mutual labels:  httpclient
Milkomeda
Spring extend componets which build from experience of bussiness, let developers to develop with Spring Boot as fast as possible.(基于Spring生态打造的一系列来自业务上的快速开发模块集合。)
Stars: ✭ 117 (+680%)
Mutual labels:  httpclient
Http Api Invoker
一个让http接口调用跟调用本地方法一样自然优雅的项目
Stars: ✭ 147 (+880%)
Mutual labels:  httpclient
Httpclientutil
HttpClient工具类,简单轻松的实现get,post,put和delete请求
Stars: ✭ 165 (+1000%)
Mutual labels:  httpclient
Resty
The minimalist framework of RESTful(server and client) - Resty
Stars: ✭ 1,268 (+8353.33%)
Mutual labels:  httpclient
HttpClientMock
Library for mocking Apache HttpClient.
Stars: ✭ 41 (+173.33%)
Mutual labels:  httpclient
Heimdall
An enhanced HTTP client for Go
Stars: ✭ 2,132 (+14113.33%)
Mutual labels:  httpclient
Yurunhttp
YurunHttp 是开源的 PHP HTTP 客户端,支持链式操作,简单易用。完美支持Curl、Swoole 协程。QQ群:17916227
Stars: ✭ 197 (+1213.33%)
Mutual labels:  httpclient
Mootool
A handy tool set for developers. 开发者常备小工具
Stars: ✭ 141 (+840%)
Mutual labels:  httpclient
Funiture
慕课网课程推荐 Java并发编程与高并发解决方案:http://coding.imooc.com/class/195.html Java开发企业级权限管理系统:http://coding.imooc.com/class/149.html github: https://github.com/kanwangzjm/funiture, spring项目,权限管理、系统监控、定时任务动态调整、qps限制、sql监控(邮件)、验证码服务、短链接服务、动态配置等
Stars: ✭ 1,786 (+11806.67%)
Mutual labels:  httpclient
Book118 Downloader
基于java的book118文档下载器
Stars: ✭ 187 (+1146.67%)
Mutual labels:  httpclient
Webapiclient
An open source project based on the HttpClient. You only need to define the c# interface and modify the related features to invoke the client library of the remote http interface asynchronously.
Stars: ✭ 1,618 (+10686.67%)
Mutual labels:  httpclient
Angular11 App
Angular 11 ,Bootstrap 5, Node.js, Express.js, CRUD REST API, PWA, SSR, SEO, Angular Universal, Lazy Loading, PostgreSQL, MYSQL
Stars: ✭ 233 (+1453.33%)
Mutual labels:  httpclient
Api Client Generator
Angular REST API client generator from Swagger YAML or JSON file with camel case settigs
Stars: ✭ 92 (+513.33%)
Mutual labels:  httpclient
Tiny.restclient
Simpliest Fluent REST client for .NET
Stars: ✭ 158 (+953.33%)
Mutual labels:  httpclient
esa-httpclient
An asynchronous event-driven HTTP client based on netty.
Stars: ✭ 82 (+446.67%)
Mutual labels:  httpclient
rawhttp
Raw HTTP client in Go for complete request control and customization.
Stars: ✭ 100 (+566.67%)
Mutual labels:  httpclient
Httplug
HTTPlug, the HTTP client abstraction for PHP
Stars: ✭ 2,295 (+15200%)
Mutual labels:  httpclient

Smart-api-framework - a light, common http api automation framework

Smart-api-framework is a light, common http api automation framework based on TestNG and HttpClient.

  • Tags: TestNG, HttpClient, XML, API, Automation, Test, Keyword-driver

Features

  • Support keyword-driver, no coding and easy to config
  • Support to execute run/debug test from xml directly due to the intellij idea plugin Aping
  • Support restful web server such as get, post, put and delete http method
  • Support concurrent
  • Re-run failed test cases
  • Easy integration with CI system

Architecture

Architecture

XML Structure

TestSuite -- config test url and httpMethod
    Function -- shared method for all case in current suite, only init once
    TestCase
        Before -- preset environment such as database
        Setup -- config setup url and httpMethod, such as login action
            Param -- config setup parameters
        Headers -- config request headers 
            Header -- config Header parameters
            Cookie -- config Cookie parameters
        Param -- config test parameters
        ExpectResults -- config expect result
            Contain	-- assert actual result contain specify string
            Pair -- assert actual result contain specify key-value
            AssertTrue -- assert expression is true
        After -- reset environment

Example

   Support shared function for all case in current suite, only init once

<TestSuite url="getMethod?" httpMethod="get">
    <Function name="suiteFunctionValue" clsName="test.java.LogicHandler" methodName="getSuiteFunctionValue" arguments="7936160"/>
    <Function name="SuiteFunctionMap" clsName="test.java.LogicHandler" methodName="getSuiteFunctionMap"/>
    <TestCase name="getMethod" desc="getMethod">
        <Before>
            <Function clsName="test.java.LogicHandler" methodName="update" arguments="1,0"/>
        </Before>
        <Setup name="setup" url="login" httpMethod="post">
            <Param name="username" value="13636426195">
            </Param>
            <Param name="password" value="bddeaa7037632c856a6b83e4037f314a" />
        </Setup>
        <Headers>
            <Header name="m-appkey" value="4272" />
            <Cookie name="unb" value="2020967487" />
        </Headers>
        <Param name="parameter1" value="#setup.errorCode+1#" />
        <Param name="parameter2" value="#suiteFunctionValue#" />
        <Param name="parameter3" value="#SuiteFunctionMap.key#" />
        <ExpectResults>
            <Pair>errorCode:#setup.errorCode#或者#setup.errorCode+1#</Pair>
            <Pair>errorMsg:约课成功</Pair>
            <Pair>errorMsg:#if(setup.errorCode==200){
                return "约课成功";
                }
                return "约课失败";#</Pair>
            <Contain>.*errorMsg.*</Contain>
        </ExpectResults>
        <After>
            <Function clsName="test.java.LogicHandler" methodName="reset"/>
        </After>
    </TestCase>
</TestSuite>

   Support function/sql action in before/after

<TestSuite url="V1/Students/login" httpMethod="post">
    <TestCase name="data1" desc="更改手机号登录">
        <Before>
            <Function clsName="test.java.LogicHandler" methodName="changeStudentsMobile" arguments="1"/>
            <Sql>update ebk_students set mobile=18078788787 where id=123456;</Sql>
        </Before>
        <Param name="username" value="#sql1.mobile#">
            <Sql name="sql">select trim(mobile) as mobile,password from ebk_students where id=123456;
            </Sql>
        </Param>
        <Param name="password" value="#sql.password#" />
        <ExpectResults>
            <Pair>errorCode:200</Pair>
            <Pair>errorMsg:登录成功</Pair>
        </ExpectResults>
        <After>
            <Function clsName="test.java.LogicHandler" methodName="resertStudentMobile"/>
            <Sql>update ebk_students set mobile=888888888 where id=123456;</Sql>
        </After>
    </TestCase>
</TestSuite>

   Support execute setup action before execution of test method

<TestSuite url="V1/ClassRecords/bookClass/" httpMethod="put">
  <TestCase name="data1" desc="约课成功">
        <Setup name="setup1" url="V1/Students/login/" httpMethod="post">
            <Param name="username" value="#sql1.mobile#">
                <Sql name="sql1">select id,mobile,password from ebk_students where status=1 and acoin>100 
                and level is not null;
                </Sql>
            </Param>
            <Param name="password" value="#sql1.password#" />
        </Setup>
        <Param name="cid" value="#sql4.id#">
            <Sql name="sql4">select id from ebk_class_records where status=0 and begin_time>unix_timestamp()
             and free_try=0 ;
            </Sql>
        </Param>
        <ExpectResults>
            <Pair>errorCode:200</Pair>
            <Pair>errorMsg:约课成功</Pair>
        </ExpectResults>
    </TestCase>
</TestSuite>

   Support get param's value from setup action response

<TestSuite url="V1/ClassRecords/bookClass/" httpMethod="put">
  <TestCase name="data1" desc="约课成功">
        <Setup name="setup1" url="V1/Students/login/" httpMethod="post">
            <Param name="username" value="#sql1.mobile#">
                <Sql name="sql1">select id,mobile,password from ebk_students where status=1 and acoin>100 
                and level is not null;
                </Sql>
            </Param>
            <Param name="password" value="#sql1.password#" />
        </Setup>
        <Param name="cid" value="#setup1.id#" />
        <ExpectResults>
            <Pair>errorCode:200</Pair>
            <Pair>errorMsg:约课成功</Pair>
        </ExpectResults>
    </TestCase>
</TestSuite>

   Support to get param's value from sql/function

<TestSuite url="V1/Students/login" httpMethod="post">
    <TestCase name="data3" desc="登录成功">
        <Param name="username" value="#sql1.mobile#">
            <Sql name="sql">select trim(mobile) as mobile from ebk_students where password =
                'e10adc3949ba59abbe56e057f20f883e'  and tx_sig_expiredtime> curdate()+86400;
            </Sql>
        </Param>
        <Param name="password" value="e10adc3949ba59abbe56e057f20f883e" />
        <Param name="code">
            <Function clsName="test.java.LogicHandler" methodName="codeGenerator" arguments="test"/>
        </Param>
        <ExpectResults>
            <Pair>errorCode:200</Pair>
            <Pair>errorMsg:登录成功</Pair>
        </ExpectResults>
    </TestCase>  
<TestSuite>

   Support Pair/Contain/AssertTrue type for expect results

<TestSuite url="V1/Students/login" httpMethod="post">
    <TestCase name="data3" desc="登录成功">
        <ExpectResults>
            <Pair>errorCode:#code#</Pair>
            <Contain>.*("id":"#sql.mobile#").*</Contain>
            <AssertTrue>"#code#"=="#sql.mobile#"</AssertTrue>
            <Sql name="sql">select trim(mobile) as mobile from ebk_students where password =
                            'e10adc3949ba59abbe56e057f20f883e'  and tx_sig_expiredtime> curdate()+86400;
                        </Sql>
            <Function name="code" clsName="test.java.LogicHandler" methodName="codeGenerator" />
        </ExpectResults>
    </TestCase>  
<TestSuite>

   Support sql/function for expect results

<TestSuite url="V1/Students/login" httpMethod="post">
    <TestCase name="data3" desc="登录成功">
        <ExpectResults>
            <Pair>errorCode:#code#</Pair>
            <Contain>.*("id":"#sql.mobile#").*</Contain>
            <Sql name="sql">select trim(mobile) as mobile from ebk_students where password =
                            'e10adc3949ba59abbe56e057f20f883e'  and tx_sig_expiredtime> curdate()+86400;
                        </Sql>
            <Function name="code" clsName="test.java.LogicHandler" methodName="codeGenerator" />
        </ExpectResults>
    </TestCase>  
<TestSuite>

   Support regular expression for expect result in contain/pair both

<TestSuite url="V2/ClassRecords/classDetail/" httpMethod="get">
    <TestCase name="GetClassDetailSuccess" desc="获取数据成功">
         <Param name="username" value="#sql.mobile#">
             <Sql name="sql">select c.begin_time as begin_time,s.mobile as mobile ,password,c.id as cid 
             from ebk_students as s left join ebk_class_records as c ON s.id = c.sid limit 100;
             </Sql>
        </Param>
        <Param name="password" value="#sql.password#" />
        <Param name="cid" value="#sql.cid#" />
        <ExpectResults>
            <Pair>errorCode:200</Pair>
            <Pair>errorMsg:老师已在(QQ|Skype)上等你,快去上课吧</Pair>
            <Contain>.*("id":"#sql.cid#").*("begin_time":"#sql.begin_time#").*</Contain>
        </ExpectResults>
    </TestCase>
</TestSuite>

   Support execute repeated times(invocationCount)

<TestSuite url="V1/Students/login" httpMethod="post" invocationCount="2000">
    <TestCase name="data1" desc="更改手机号登录">
        <Param name="username" value="#sql1.mobile#">
            <Sql name="sql">select trim(mobile) as mobile,password from ebk_students where id=123456;
            </Sql>
        </Param>
        <Param name="password" value="#sql.password#" />
        <ExpectResults>
            <Pair>errorCode:200</Pair>
            <Pair>errorMsg:登录成功</Pair>
        </ExpectResults>
    </TestCase>
<TestSuite>

   Support request headers

<TestSuite url="V1/Students/login" httpMethod="post">
    <TestCase name="data1" desc="更改手机号登录">
        <Headers>
            <Header name="Content-Type" value="application/x-www-form-urlencoded;charset=UTF-8" />
            <Cookie name="PHPSESSIONID" value="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
        </Headers>
        <Param name="key" value="value" />
        <ExpectResults>
            <Pair>errorCode:200</Pair>
            <Pair>errorMsg:成功</Pair>
        </ExpectResults>
    </TestCase>
<TestSuite>

Demo project please refer to smart-api-automation-example

Contributors

Charlie https://github.com/zhuyecao321
Niki https://github.com/ZhangyuBaolu
Wind https://github.com/lwfwind

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].