Importing a data table (.csv file)

HCL OneTest Embedded Component Testing for C and C++ provide the ability to import .csv table files and to turn these into standard .h header files. The resulting header file uses the same filename with a .h extension. Once included in your .ptu or .otd test script, this data can be used by the test driver script or the application under test.

Such .csv files can be produced by most spreadsheet programs or a text editor.

To import a .csv file into a test node:

  1. From the Project Explorer, right click an existing test node.
  2. From the pop-up menu, select Add File...
  3. Locate and select the .csv file and click OK.
  4. By default, added files are excluded from the build. Click theExcludedmarker to allow the file to be built. The.csvtable file must be located before the.ptutest script in the test node.
  5. Edit the .ptu test script to manually add an include statement of the resulting .h header file.

Note The .csv data table file must be located before the .ptu test script in the test node. If not, then you must manually build the .csv data table file before building the test node.

CSV File Format

The formatting rules for the .csv file are as follow:

  • The first line contains the names of the variable arrays separated by the default CSV separator specified in the preferences or the Configuration settings.

  • The second line optionally specifies the data type:string,charorint,long,floatanddouble, which can besignedorunsigned. if this information is not specified, thenintis assumed by default.

  • Each following line contains the data for the corresponding array

  • When a blank value is encountered, an end of array is assumed. Any further values for that array will be ignored.

When the test node is built, HCL OneTest Embedded produces a <filename> .h header file, where <filename> is based on the name of the input <filename> .csv file.

Use the arrays produced by the .csv file by including <filename> .h into your test script or source code.

The separator options for the .csv file are defined in two locations:

  • Data tables preferences: These specify the default behavior for HCL OneTest Embedded.

  • Data tables section in the General Configuration settings: These allow you to override the default settings for a particular project of test node.

Example

This is an example of a valid table.csv data table:

var_A;var_B;var_C

int;signed int;float

12;34;45.2345

14;2;3.142

;-5;0

This produces the following corresponding table.h file:

int var_A[]={12,14};

signed int var_B[]={34,2,-5};

float var_C[]={45.2345,3.142,0};

Related Topics

General Settings | Data table preferences