Tutorial: Import test data - iks-gmbh-tools/SysNat GitHub Wiki

Back


In most cases it is not a good idea to "hard code" test data values within the natural language instructions of the executable examples (content of the nlxx files). Instead it is helpful to create bundles of test data values that describe a test object and write such bundles into separate test data files. Here you learn how to use test data files.

Note: Any test data file referenced in a nlxx file is supposed to be located anywhere in the testdata/<test application> folder. It need not to be located in this root and is also found in any subfolder as long as the file name is unique.

  1. Open file "./sysnat.natural.language.executable.examples/ExecutableExamples/GoogleSearch/WebPageCheck.nlxx".

  2. Replace line 'Enter search text "SysNat".' by the new line 'Enter search text "::SearchText".'

  3. Replace line 'Search results contain "https://github.com/iks-github/SysNat".' by the new line 'Search results contain "::ExpectedSearchResultText1".'

  4. Replace line 'Search results contain "Operate your software system".' by the new line 'Search results contain "::ExpectedSearchResultText2".'

  5. Add line 'TestData: GoogleSearchSysNat' below the XX line.

  6. Create new text file "./sysnat.natural.language.executable.examples/testdata/GoogleSearch/GoogleSearchSysNat.dat".

  7. Give the new test data file the following content:

     SearchText=SysNat
     ExpectedSearchResultText1=https://github.com/iks-github/SysNat
     ExpectedSearchResultText2=Operate your software system
    
  8. Finally, the placeholders must be mapped onto the values loaded from the test data file. First, add as first line in method LanguageTemplatesGoogleSearchBasics.checkSearchResult:

     possibleMatch = executableExample.getTestDataValue(possibleMatch);
    

Second, add as first line in method LanguageTemplatesGoogleSearchBasics.enterSearchText:

     searchString = executableExample.getTestDataValue(searchString);
  1. Rebuild the code, start SysNat and check the test report.

  2. In the nlxx file write a second executable example with the same instructions but a different test data file.

  3. Create the test data file for the second executable example with any data of your choice.

  4. Start SysNat and read the error message. Introduce a behaviour declaration.

  5. Restart and check that the test is successful.


Back