An open API service indexing awesome lists of open source software.

https://github.com/lwfwind/smart-api-framework

smart api automation framework to support web service api automaton test based on testng and httpclient
https://github.com/lwfwind/smart-api-framework

api automation http httpclient keyword-driver testng

Last synced: 13 days ago
JSON representation

smart api automation framework to support web service api automaton test based on testng and httpclient

Awesome Lists containing this project

README

          

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

Smart-api-framework is a light, common http api automation framework based on [TestNG](http://testng.org/doc/index.html) and [HttpClient](http://hc.apache.org/httpcomponents-client-ga/).

* 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](https://github.com/lwfwind/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](https://github.com/lwfwind/smart-api-framework/blob/dev/pics/Architecture.png)

## XML Structure
```xml
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
```xml




















errorCode:#setup.errorCode#或者#setup.errorCode+1#
errorMsg:约课成功
errorMsg:#if(setup.errorCode==200){
return "约课成功";
}
return "约课失败";#
.*errorMsg.*




```
###    Support function/sql action in before/after
```xml




update ebk_students set mobile=18078788787 where id=123456;


select trim(mobile) as mobile,password from ebk_students where id=123456;




errorCode:200
errorMsg:登录成功



update ebk_students set mobile=888888888 where id=123456;

```

###    Support execute setup action before execution of test method
```xml




select id,mobile,password from ebk_students where status=1 and acoin>100
and level is not null;





select id from ebk_class_records where status=0 and begin_time>unix_timestamp()
and free_try=0 ;



errorCode:200
errorMsg:约课成功

```

###    Support get param's value from setup action response
```xml




select id,mobile,password from ebk_students where status=1 and acoin>100
and level is not null;






errorCode:200
errorMsg:约课成功

```

###    Support to get param's value from sql/function
```xml



select trim(mobile) as mobile from ebk_students where password =
'e10adc3949ba59abbe56e057f20f883e' and tx_sig_expiredtime> curdate()+86400;







errorCode:200
errorMsg:登录成功

```

###    Support Pair/Contain/AssertTrue type for expect results
```xml



errorCode:#code#
.*("id":"#sql.mobile#").*
"#code#"=="#sql.mobile#"
select trim(mobile) as mobile from ebk_students where password =
'e10adc3949ba59abbe56e057f20f883e' and tx_sig_expiredtime> curdate()+86400;



```

###    Support sql/function for expect results
```xml



errorCode:#code#
.*("id":"#sql.mobile#").*
select trim(mobile) as mobile from ebk_students where password =
'e10adc3949ba59abbe56e057f20f883e' and tx_sig_expiredtime> curdate()+86400;



```

###    Support regular expression for expect result in contain/pair both
```xml



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;





errorCode:200
errorMsg:老师已在(QQ|Skype)上等你,快去上课吧
.*("id":"#sql.cid#").*("begin_time":"#sql.begin_time#").*

```

###    Support execute repeated times(invocationCount)
```xml



select trim(mobile) as mobile,password from ebk_students where id=123456;




errorCode:200
errorMsg:登录成功

```

###    Support request headers
```xml








errorCode:200
errorMsg:成功

```

Demo project please refer to [smart-api-automation-example](https://github.com/lwfwind/smart-api-automation-example)

## Contributors
Charlie [https://github.com/zhuyecao321](https://github.com/zhuyecao321)

Niki [https://github.com/ZhangyuBaolu](https://github.com/ZhangyuBaolu)

Wind [https://github.com/lwfwind](https://github.com/lwfwind)