Access Keys:
Skip to content (Access Key - 0)
Log in (Access Key - 5)



Toggle Sidebar

Datasets

Datasets are the successor of Molybdenum variable files.

Disadvantages of variable files removed by datasets:

  • loadable from url relative to the testsuite
  • variables organized in scopes, scope is selected with the load command
  • simple converters written in javascript can create and convert data

Dataset file format

The dataset file format can be loosly defined by following DTD

<!ELEMENT dataset ( converters?, data ) >
<!ELEMENT converters ( converter )+ >
<!ELEMENT converter ( #PCDATA ) >
<!ELEMENT data ANY >

The data element contains one or more scope elements. Each scope element can contain one or more variable elements.
See the example below.

dataset.xml
<dataset>
  <converters>
    <converter>converter.js</converter>
  </converters>
  <data>
    <myscope1>
      <myvar1>foo</myvar1>
      <myvar2>bar</myvar2>
    </myscope1>
    <myscope2>
      <myvar1>anotherfoo</myvar1>
      <myvar2>anotherbar</myvar2>
    </myscope2>
  </data>
</dataset>

A converter element holds an url, relative to the dataset.xml or absolute referencing a javascript file. Following an example of such a file.

converter.js
dynamicvar = String(myvar1 + "dynamic");

The example above will result in following variables and its values:

For scope myscope1
myvar1 = foo
myvar2 = bar
dynamicvar =  foodynamic
For scope myscope2
myvar1 = anotherfoo
myvar2 = anotherbar
dynamicvar =  anotherfoodynamic

Loading datasets

The command loadData (dataURL, scope) will be used to load a dataset.
The dataURL will be resolved relative to the testsuite.

Example
loadData | dataset.xml | myscope1

Converters in detail

Converters are javascript snippets to be executed in the scope of the dataset. This means, all variables defined in the selected scope of the dataset are visible as global javascript variables. Nothing else is accessible from the converter javascript, nor window or browser object neither any XPCom functionality. But standard javascript functionality like the Math object is available.
New variables can be defined as global variables and will be visible in Molybdenum as variables afterwards, but only variables of type String will be made visible to Molybdenum. Therefore strong typing like var = String(value) is a good idea.

last edited on Apr 28, 2009 09:17
Adaptavist Theme Builder Powered by Atlassian Confluence