Accessing Test Data

CTestStep provides a parser for input (.ini) files which can be called from test steps. It can be used as a means of providing different sets of test data for different test scenarios that reduces the need to hard code test data within the test step.

The following example code shows the calls that can be made in a test step to access and update the data in a .ini file.

TVerdict CSampleStep1::doTestStepL()
{
WriteStringToConfig(ConfigSection(),_L("TheString"),val); // Write string values to ini
WriteBoolToConfig(sectName,_L("TheBool"),changeBool); // Write Bool values to ini
WriteIntToConfig(ConfigSection(),_L("TheInt"),changeInt); // Write Int values to ini
WriteHexToConfig(sectName,_L("TheHex"),changeHex); // Write Hex values to ini
GetHexFromConfig(sectName,_L("TheHex"),changeInt); // Read Hex values from ini
GetIntFromConfig(ConfigSection(),_L("TheInt"),theInt); // Read Int values from ini
GetBoolFromConfig(ConfigSection(),_L("TheBool"),theBool); // Read Bool values from ini
GetStringFromConfig(ConfigSection(),_L("TheString"),theString); // Read string values from ini
}

The functions in this example code takes three parameters:

  • The first parameter is the section name in the .ini file where the data is being read from or written to. This can be either a string containing the section name or a call to ConfigSection(), which reads the name provided by a RUN_TEST_STEP or variant command.

  • The second parameter is a string containing the key name for the data within the specified section.

  • The third parameter is the variable into which the data can be read or which holds the value to be written.