Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/lchrennew/g-stack

让你无需写代码就能搞定的自动化验收/接口测试,基于Gauge的全栈测试平台
https://github.com/lchrennew/g-stack

api bdd gauge uitest

Last synced: 22 days ago
JSON representation

让你无需写代码就能搞定的自动化验收/接口测试,基于Gauge的全栈测试平台

Awesome Lists containing this project

README

        

# G-Stack
让你无需写代码就能搞定的自动化验收/接口测试,基于Gauge的全栈测试平台

[![Gauge Badge](https://gauge.org/Gauge_Badge.svg)](https://gauge.org)

## Requirements
* Maven 3+
* Java 1.8+
* Gauge
* IDEA
* Gauge plugins: guage-java, gauge-java, gauge-java-maven, gauge-intellij-idea, gauge-html-report

## DSL reference
### Syntax
G-Stack Syntax is fully compatible with Gauge, reference [here](https://docs.gauge.org/latest/writing-specifications.html) for more detail on Gauge Syntax

### Basic Syntax
* If you want to print messages into both console & reports:

`PRINT "content"`

* If you want to assert an actual value to an expected value:
```markdown
* ASSERT
```
build-in matches: `=`, `<>`, `!=`, `contains`

* If you want to assert multiple actual values to their expected values one by one in one step:

```markdown
* ASSERT
```
`` format:
```markdown
|actual|match|expected|
|------|-----|--------|
```

* If you want execution to be paused for seconds:

`* WAIT `

* If you want to share data between steps, scenarios or specs:

``` markdown
* SET:SCENARIO
* SET:SPEC
* SET:SUITE
```
or share multiple values:
```markdown
* SET:SCENARIO
* SET:SPEC
* SET:SUITE
```
`` format:
```markdown
|name|value|
|----|-----|
|m |4 |
|n |5 |
// @{m} => 4
// @{n} => 5
```
or dynamic table
```markdown
|col1|col2|col3|
|----|----|----|
|x |10 |20 |
// @{col1.x.col2} => 10
// @{col1.x.col3} => 20
```
or dynamic table with explicitly id column
```markdown
|col1#|col2|col3|
|-----|----|----|
|x |10 |20 |
// @{col1.x.col2} => 10
// @{col1.x.col3} => 20

```

* After set value to their name, you could get the value by our Argument Syntax:
`@{name}`

#### Arguments
```markdown
* SET:SCENARIO "hello" "world"
* SET:SCENARIO "suffix" "llo"
* PRINT "@{hello}"
* PRINT "I will say: @{hello}"
* PRINT "hello, @{he@{suffix}}!"
```

The output will be:
```text
world
I will say: world
hello, world!
```

#### Dynamic Arguments
There are some arguments whose value can be generated automatically.
Build-in dynamic arguments:

```markdown
@{timestamp}
```

### HTTP Syntax
#### Arrange Request
* If you want to set baseUri:
```markdown
* BASE
```
* If you want to set basePath:
```markdown
* PATH
```

* If you want to add query parameters to Url
```markdown
* QUERY
```
or
```markdown
* QUERY
```
`` format:
```markdown
|name|value|
|----|-----|
```
e.g.
```markdown
* QUERY "a" "1"
* QUERY "a" "2"
* QUERY
|name|value|
|----|-----|
|b |1 |
|c |2 |
|c |3 |
```
the final query string will be
```markdown
?a=1&a=2&b=1&c=2&c=3
```

* If you want to add request headers:
```markdown
* HEADER
```
or (`` format is same to `QUERY`)
```markdown
* HEADER
```

* If you want to add cookies:
```markdown
* COOKIE
```
or (`` format is same to `QUERY`)
```markdown
* COOKIE
```

* If you want to set Content-Type
```markdown
* CONTENTTYPE
```
or
```markdown
* CONTENTTYPE
```

* If you want to add form parameters:
```markdown
* BODY:FORM
```
or (`` format is same to `QUERY`)
```markdown
* BODY:FORM
```

* If you want to add text content to body:
```markdown
* BODY:CONTENT
```

* If you want to build a whole new request:
```markdown
* REQUEST:NEW
```

* If you want to build a whole new request from a config file:
```markdown
* HTTP:SETUP
```
e.g.
```markdown
* HTTP:SETUP
```
```json
{
"method": "GET",
"baseUri": "https://requestloggerbin.herokuapp.com",
"basePath": "/",
"httpVersion": "HTTP/1.1",
"cookies": {
"c1": "d4c19a20393919416cc88d29a4dec3cbe1528282256",
"c2": "null"
},
"headers": {
"accept": "application/json",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8"
},
"queryString": {
"a": [
"1",
"2"
],
"b": "3"
},
"postData": {
"mimeType": "application/x-www-form-urlencoded",
"forms": {
"c": [
"5",
"4"
],
"d": "6"
}
}
}
```

#### Http Act
* If you want to send GET request:
```markdown
* GET
```

* If you want to send POST request:
```markdown
* POST
```
or
```markdown
* POST
```

#### Assert Response
* If you want to assert response status code:
```markdown
STATUS
```

* If you want to assert response body content:
```markdown
// entirely match
* CHECK:BODY

// partial match
* CHECK:CONTENT

// not match
* FAIL:BODY

// not contain
* FAIL:CONTENT

```

* If you want to check response as a JSON by GPath (Note that the `` is a GPath)
```markdown
* CHECK:JSONPATH
* FAIL:JSONPATH

```
or
```markdown
* CHECK:JSONPATH
```
`` format:
```markdown
|path|value|
|----|-----|
```

* If you want to check response as a JSON by JSON Schema Validation:
```markdown
* CHECK:JSONSCHEMA
```

* If you want to check response headers:
```markdown
// header with expected value
* CHECK:HEADER

// not exist header
* CHECK:HEADER null
```

* If you want to check response cookies:
```markdown
* CHECK:COOKIE
* CHECK:COOKIE null
```

#### Extract response values
If you want to share response data between steps or scenarios in current specification, you could use extraction syntax.

* If you want to extract body content:
```markdown
* EXTRACT:CONTENT
```

* If you want to extract value of a GPath
```markdown
* EXTRACT:JSONPATH
```

* If you want to extract headers
```markdown
* EXTRACT:HEADER
```

* If you want to extract cookies
```markdown
* EXTRACT:HEADER
```

#### Log requests and response
* If you want to log requests and response into console or report:
```markdown
// before the request is sent
* HTTP:LOG
```

### MySql Syntax
* If you want to execute single sql statement:
```markdown
* SQL:STATEMENT
```

* If you want to execute assertion in sql:
```markdown
// returns 0 for fail and 1 for pass
* SQL:ASSERT
```

* If you want to execute batch sql statements:
```markdown
* SQL:SCRIPT
```

* If you want to execute insert and share auto-generated id with other steps:
```markdown
* SQL:INSERT
```
note that the `` is a dynamic table with explicitly id column:
```markdown
|col1#|col2|col3|
|-----|----|----|
|x |10 |20 |
// @{col1.x.id} => new generated id
// @{col1.x.col2} => 10
// @{col1.x.col3} => 20
```

### Web UI Syntax
* If you want to use Web UI Automation, you must use scope syntax first:
```markdown
* UI:WEB BEGIN
// perform some actions here
* UI:WEB END
```

* If you want to open browser:
```markdown
* OPEN
```

* If you want to define an element with a name:
```markdown
DEF
```

* If you want to enter text into element:
```markdown
* ENTER
```

* If you want to click on an element:
```markdown
* CLICK
```

* If you want to submit an element:
```markdown
* SUBMIT
```

* If you want to close browser:
```markdown
* QUIT
```

## License

![GNU Public License version 3.0](http://www.gnu.org/graphics/gplv3-127x51.png)
G-Stack is released under [GNU Public License version 3.0](http://www.gnu.org/licenses/gpl-3.0.txt)

## Copyright

Copyright 2018 CHUN.LI