JSON Data File formats

Now that we have the JSON Data Provider created, we need some data in the correct format. Users can actually customize the formatting of the JSON data in the files. Again, JSON is based on the key/value pairs of data, and the schema is somewhat subjective as to how you lay out the data:

There is a helpful JSON formatting tool located at https://jsonformatter.curiousconcept.com/.
// the following sets of JSON data are laid out vertically

{
"tc001_getBandInfo":[
{
"rowID":"tc001_getBandInfo.01",
"description":"Kiss Data",
"name":"Kiss",
"year":"1973",
"song":"Rock and Roll All Nite",
"members":{
"Vocals":"Paul Stanley",
"Bass":"Gene Simmons",
"Guitar":"Ace Frehley",
"Drums":"Peter Criss"
}
},
{
"rowID":"tc001_getBandInfo.02",
"description":"Van Halen Data",
"name":"Van Halen",
"year":"1972",
"song":"Dance the Night Away",
"members":{
"Vocals":"David Lee Roth",
"Bass":"Michael Anthony",
"Guitar":"Eddie Van Halen",
"Drums":"Alex Van Halen"
}
},
{
"rowID":"tc001_getBandInfo.03",
"description":"U2 Data",
"name":"U2",
"year":"1976",
"song":"Sunday Bloody Sunday",
"members":{
"Vocals":"Bono",
"Bass":"Adam Clayton",
"Guitar":"The Edge",
"Drums":"Larry Mullen"
}
},
{
"rowID":"tc001_getBandInfo.04",
"description":"Thin Lizzy Data",
"name":"Thin Lizzy",
"year":"1969",
"song":"The Boys Are Back in Town",
"members":{
"Vocals":"Phil Lynott",
"Bass":"Phil Lynott",
"Guitar":"Scott Gorham",
"Drums":"Brian Downey"
}
}
]
}
// the following sets of JSON data are laid out horizontally

{
"tc002_addEmp":
[
{"rowID":"tc002_addEmp.01","description":"Add
Employee"
,"id":"EMP1","name":"John","gender":"M","age":23},

{"rowID":"tc002_addEmp.02","description":"Add
Employee"
,"id":"EMP2","name":"Jane","gender":"F","age":30},

{"rowID":"tc002_addEmp.03","description":"Add
Employee"
,"id":"EMP3","name":"Sally","gender":"F","age":19},
 {"rowID":"tc002_addEmp.04","description":"Add 
Employee"
,"id":"EMP4","name":"Bob","gender":"M","age":40}
]
}

Note that in both examples, there is a method name that starts the data model, and each set of data for that method is nested within it. For instance, in the first example, the method name is tc001_getBandInfo, which will be the name of the Java test method in the test class. Each set of data to be passed into it has rowID using the same name plus an index such as tc001_getBandInfo.01, tc001_getBandInfo.02, and so on.

For the next test method set of data, the user can include it in the same JSON file, but must differentiate the method name.

The second example uses the method name tc002_addEmp with the rowID as tc002_addEmp.01, tc002_addEmp.02, and so on. How the data is structured in the JSON file is determined by JSONObject, which is being created for the test method. We will cover that in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.221.113