Appearance
Data Driven Testing
Data-driven testing allows you to run the same test logic multiple times with different inputs, without duplicating test scripts.
Instead of hard-coding values into your test:
js
I.fill("Email", "[email protected]")
I.fill("Password", "secret123")You parameterise your test:
js
I.fill("Email", DATA.email)
I.fill("Password", DATA.password)…and let UI-licious supply the data.
In UI-licious, data-driven testing is typically achieved using a combination of:
- Datasets - test-specific variables and secrets
- Environments - shared environment variables and secrets
- External data files – JSON or CSV files
Using Datasets
In Web IDE and TAMI Studio, you can create Datasets to store test variables and secrets.
For example, you can create a Dataset named "admin_user", with the following data:
| Property | Value |
|---|---|
DATA.email | [email protected] |
DATA.password | ************** |
In the test script, you can use a dataset property as such:
js
I.fill("Email", DATA.email)
I.fill("Password", DATA.password)
I.click("Log In")When you run the test, the values will be populated from the selected Dataset.
INFO
Note that in Web IDE, Datasets are project-scoped. But in TAMI Studio, Datasets are scoped to individual test cases by default, and cannot be used in other test cases unless set to project-scoped.
Related links:
- Learn more about using Datasets in Web IDE
- Learn more about using Datasets in TAMI Studio
Using Environments
INFO
Environments is only available in TAMI Studio.
Environments work the same way as Datasets, except that they are intended for shared global variables and secrets like urls.
In the test script, you can use an environment property as such:
js
I.goTo(ENV.url)When you run the test, the values will be populated from the selected Environment.
You can use both Datasets and Environments together:
js
I.goTo(ENV.url)
I.fill("Email", DATA.email)
I.fill("Password", DATA.password)
I.click("Log In")Related links:
- Learn more about using Environments in TAMI Studio
Loading Test Data from Files
UI-licious allows you to load test data from a CSV or JSON file, which is useful for large datasets.
Loading a JSON file
For example, given a data file "data/employees.json" with the following structure:
json
[
{ "id": "001", "name": "John Smith", "dept": "HR" },
{ "id": "002", "name": "Jane Doe", "dept": "Engineering" }
]You can load the data from the file using TEST.loadDataFromJson():
js
var employees = TEST.loadDataFromJson("./data/employees.json")
employees.forEach((person)=>{
I.see(person.name)
})Related links:
- Learn more about TEST.loadDataFromJson()
Loading a CSV file
For example, given a data file "data/employees.csv" with the following structure:
csv
id,name,dept
001,John Smith,HR
002,Jane Doe,EngineeringYou can load the data from the file using TEST.loadDataFromCsv(), with the option {header: "row"} to specify that the property names are in the first row:
js
var employees = TEST.loadDataFromCsv("./data/employees.csv", {header: "row"})
employees.forEach((person)=>{
I.see(person.name)
})Related links:
- Learn more about TEST.loadDataFromCsv()