-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: added support parameters from data files
```javascript // qase.parameters: userId, user.name pm.test("Status code is 201", function() { pm.response.to.have.status(201); }); ```
- Loading branch information
Showing
5 changed files
with
194 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
# [email protected] | ||
|
||
## What's new | ||
|
||
Added support parameters from data files in Newman. | ||
How to use parameters from data files in Newman, see [here](./docs/usage.md). | ||
|
||
# [email protected] | ||
|
||
## What's new | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# How to Use Parameters from Data Files in Newman | ||
|
||
Newman allows you to leverage parameters from data files to make your API tests more dynamic and efficient. By utilizing | ||
the `--data` or `-d` option when running a collection, you can feed your tests with various input sets. The data files | ||
can be formatted as either JSON or CSV. | ||
|
||
### Example Data File | ||
|
||
Consider the following `data.json` file, which contains user data structured as complex objects: | ||
|
||
```json | ||
[ | ||
{ | ||
"userid": 1, | ||
"user": { | ||
"name": "John", | ||
"age": 30 | ||
} | ||
}, | ||
{ | ||
"userid": 2, | ||
"user": { | ||
"name": "Jane", | ||
"age": 25 | ||
} | ||
} | ||
] | ||
``` | ||
|
||
### Example Tests | ||
|
||
Below are example tests that utilize the data parameters defined in the data file: | ||
|
||
```javascript | ||
// qase.parameters: userId, user.name | ||
pm.test("Status code is 201", function() { | ||
pm.response.to.have.status(201); | ||
}); | ||
|
||
// qase.parameters: userId | ||
pm.test("Response has correct userId", function() { | ||
var jsonData = pm.response.json(); | ||
pm.expect(jsonData.userId).to.eql(pm.iterationData.get("userid")); | ||
}); | ||
|
||
pm.test("Response has correct name", function() { | ||
var jsonData = pm.response.json(); | ||
pm.expect(jsonData.user.name).to.eql(pm.iterationData.get("user.name")); | ||
}); | ||
``` | ||
|
||
### Expected Behavior | ||
|
||
When you run the tests, the following behavior is expected: | ||
|
||
- In the **`Status code is 201`** test, both `userId` and `user.name` will be passed as parameters. | ||
- In the **`Response has correct userId`** test, only the `userId` parameter will be passed. | ||
- In the **`Response has correct name`** test, all relevant parameters from the data file will be passed, including | ||
`userId`, `user.name`, and `user.age`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters