https://github.com/actframework/act-e2e
Provide end to end test support
https://github.com/actframework/act-e2e
Last synced: 15 days ago
JSON representation
Provide end to end test support
- Host: GitHub
- URL: https://github.com/actframework/act-e2e
- Owner: actframework
- License: apache-2.0
- Created: 2018-05-01T04:55:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-08T10:49:28.000Z (over 7 years ago)
- Last Synced: 2025-07-06T02:18:38.491Z (7 months ago)
- Language: Java
- Size: 172 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# act-e2e
Support end to end test of act application
## 1. Usage
### 1.1 Files
act-e2e use all settings in `e2e` profile to run e2e test. In addition to settings (found `resources/conf/e2e`), the following files in `resources` are read by act-e2e plugin to run e2e test:
* `resources/e2e/fixtures/*`
- stores all data fixtures files prepared for testing environment
* `resources/e2e/scenarios.yml`
- Defines test scenarios
* `resources/e2e/scenarios/*.yml`
- stores test scenarios in multiple files for easier management
* `resources/e2e/requests.yml`
- defines request templates which can be referred in request definition in scenario files
#### 1.1.1 Sample Fixture file
```yaml
Course(math):
id: 1
name: Maths
Course(history):
id: 2
name: History
User(green):
id: 1
name: Green Luo
birthday: 1919-01-01
courses:
- embed:math
User(black):
id: 2
name: Black Smith
birthday: 1818-02-02
courses:
- embed:math
- embed:history
User(john):
id: 3
name: John Brad
courses:
- id: 3
name: Physics
- id: 4
name: Science
```
#### 1.1.2 Sample Scenario file
```yaml
# Test hello service
Scenario(Hello Service):
description: a service says hello
interactions:
- description: send request to hello service without parameter
request:
method: GET
url: /hello
response:
text: Hello World # response text must be "Hello World"
- description: send request to hello servcie with parameter specified
request:
method: GET
url: /hello?who=ActFramework
response:
# this time we demonstrate verify text with a list of verifiers
text:
- eq: Hello ActFramework # value must be equal to "Hello ActFramework"
- contains: ActFramework # value must contains "ActFramework"
- starts: Hello # value must starts with "Hello"
- ends: Framework # value must ends with "Framework"
- description: send request to hello servcie with parameter specified and require JSON response
request:
json: true # specify accept type is application/json
method: GET
url: /hello?who=Java
response:
json: # treat result as a JSON object
result: Hello Java # result property of hte JSON object must be "Hello World"
# Test date service
Scenario(Date Service):
description: A service returns a date
interactions:
- description: send request to the service
request:
method: GET
url: /date
response:
text:
- before: 2000-01-01
- after: 01/Jan/1990
- description: send request to the service and request response be JSON format
request:
json: true
method: GET
url: /date
response:
json:
result:
- before: 2000-01-01
- after: 01/Jan/1990
# Test todo-task service
Scenario(task-service):
description: A basic todo task service test
interactions:
- description: Create the a task with description specified
request:
method: POST
url: /tasks
params:
task.description: TaskA
response:
json:
id: ...
description: TaskA
- description: Retrieve the Task just created
request:
method: GET
url: /tasks/${last:0.id}
response:
json:
id:
description: TaskA
- description: Create a task without description
request:
method: POST
url: /tasks
response:
status: 400
```
1.2 Run test
First make sure you have act-e2e plugin dependency in your `pom.xml` file:
```xml
org.actframework
act-e2e
${act-e2e.version}
```
At the moment the version of act-e2e version is `0.0.6`. Note if your have the following parent in your pom.xml file you get act-e2e-0.0.6 automatically, no need to add it into your dependency.
```xml
org.actframework
act-starter-parent
1.8.8.4
```
Now you can run end to end test of the app using `e2e` profile:
```
./run_prod -p e2e
```
Note if you are using act-starter-parent-1.8.8.0 you don't need to add the dependency, and you can run e2e test with maven:
```
mvn compile act:e2e
```