« Back to How To Articles

How to use XFTs to test functions

XFTs, "xDE Function Tests", are the unit test files for testing simple, string-in, string-out XDE functions, including PAL actions. This example show how to test a new PAL action using XFTs.

An XFT should be created for every new PAL action. This way you can test how the action behaves in a range of situations. You can then rerun these tests when you've updated your actions, in order to verify that they are still correct.

Fortunately creating, editing and running XFTs is very easy.

The xDE builder provides the following functionality to help you use XFTs:

  • A wizard to create an XFT.
  • An XFT editor.
  • An XFT runner shortcut.

Creating an XFT #

To create an XFT based on a PAL action:

  • Right-click on the action's PAR file in the Package Explorer.
  • Select New -> xDE Function Test. This will start a wizard which will create an XFT file based on your PAL action. On the first page the wizard will suggest a location and filename for the new XFT file.
  • In the second page of the wizard, you may populate more details of the XFT:
    • The import / name fields specify the function under test.
    • The "Test params" field allows you to enter a comma-separated list of strings for the arguments to be supplied to the function when the XFT is run.
    • The "Include CLI Response" section allows you to specify a file containing a CLI response which will form the CLI response for the transport handler of your PAL action's handler chain. You can also set the device version details in order to control which PAR rule is selected.
    • The "Run function now..." checkbox will, if ticked, cause the wizard to run the PAL action immediately in order to populate the expected result section of the XFT file.
  • When you complete the wizard, the editor will open. You can also open the editor at any point by double-clicking on the XFT file in the Package Explorer.

Running an XFT #

There are various ways to run XFTs.

1. You can run an XFT from the editor by clicking on the "Run" button at the bottom of the editor. 2. You can select one or more XFT files in the Package Explorer and then right-click and select Run As... -> xDE Function Test(s) 3. You can select one or more folders in the Package Explorer and then right-click and select Run As... -> xDE Function Test(s). This will run any XFTs found in the folder or any recursive subfolder.

If the tests pass, you will just get a short message indicating this. If a test fails, the builder will display a dialog highlighting the differences between the actual and expected results for the first failed test. The failed XFT test will be opened in the XFT editor.

0 Attachments
1922 Views
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Comments