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
- Host: GitHub
- URL: https://github.com/lwfwind/smart-api-framework
- Owner: lwfwind
- License: apache-2.0
- Created: 2016-07-05T04:39:00.000Z (over 9 years ago)
- Default Branch: dev
- Last Pushed: 2017-06-23T10:28:14.000Z (over 8 years ago)
- Last Synced: 2025-07-06T12:48:44.769Z (7 months ago)
- Topics: api, automation, http, httpclient, keyword-driver, testng
- Language: Java
- Homepage:
- Size: 502 KB
- Stars: 15
- Watchers: 7
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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

## 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)