Tester
Evaluates one or more tests on a feature, and routes the feature according to the outcome of the test(s).
Typical Uses
- Performing quality testing on data
- Dividing features into two streams based on a test
- Isolating a subset of features based on a test
How does it work?
The Tester accepts any feature. It evaluates each feature against one or more user-defined tests, and outputs the feature via the Passed port if it meets the defined conditions, or via the Failed port if it fails the defined conditions.
The tests are constructed as a series of Test Clauses, which evaluate values or expressions based on a wide range of available Operators and test types. The Test Clauses are connected with Logic - combinations of AND, OR, and NOT, with parentheses to define evaluation order.
Creating Test Clauses
Each clause is composed of a value to test, and the method of testing it. Depending on the type of test, at a minimum the clause will consist of a Left Value and an Operator. If the chosen Operator needs more information (for example, testing for an attribute that is greater than a certain value), a Right Value field is provided.
The Test Clauses are created in a table, and numbered from the top down.
Left Value |
Operator |
Right Value |
Mode* |
---|---|---|---|
The value or expression to test | The type of test to perform | The value for comparison, if required by the operator | Test the values in a specific manner |
Examples | |||
Latitude | > | 49.000001 | Automatic |
@Area() | In Range | (1,100) | Numeric |
SnackType | Like | Kebabs | Case Sensitive |
Traffic | Attribute Is Null | <Unused> | Automatic |
Count | Type Is | Integer | Automatic |
* Note that Mode is only available for individual tests when Comparison Mode is set to Specify Per Test.
Test Clause Operators
These are the Operators available for constructing test clauses. They may be used to test attribute values, constructed expressions, constants, and published parameters.
Note that (unless otherwise specified) most operators can be used with both numeric values and strings. Strings may be compared with the =, !=, <, >, <=, and >= operators, and are evaluated by their character codes, so A < B.
Operator |
Description |
Right Value Configuration |
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
= | Equal to | Enter a value for comparison. | ||||||||||||||||
!= | Not Equal to | Enter a value for comparison. | ||||||||||||||||
< | Less than | Enter a value for comparison. | ||||||||||||||||
> | Greater than | Enter a value for comparison. | ||||||||||||||||
<= | Less than or equal to | Enter a value for comparison. | ||||||||||||||||
>= | Greater than or equal to | Enter a value for comparison. | ||||||||||||||||
In Range |
Tests if the value falls within the numeric range specified in set notation. Open-ended ranges may be defined by leaving either the lower or upper limit blank. |
Range values are separated by a comma and enclosed by brackets. Square brackets - [ ] - indicate inclusive limits (greater than or equal to, less than or equal to). Round brackets - ( ) - indicate exclusive limits (greater than, less than). Valid range examples: (1,9) Greater than 1 and less than 9 [1,9] Greater than or equal to 1 and less than or equal to 9 (1,9] Greater than 1 and less than or equal to 9 (1,) Greater than 1 [,9] Less than or equal to 9 Note: This operator is not available when Mode is set to Case Sensitive or Case Insensitive, and those modes are not available when the operator is set to In Range. |
||||||||||||||||
In | Tests if the value may be found in the provided list of possible values and ranges. |
Enter any combination of comma-separated strings, numeric values, and/or ranges (in the form of x-y). Valid configuration examples: 1,10,100 1-99 cat cat,dog,cats and dogs dogs,1-9,7 String ranges (for example, a-d) can also be specified. To test for values that contain a hyphen, enclose the value in quotation marks: "LL-27","LL-83". To test for values that contain either single (') or double (") quotes, enclose the value in the opposing quotes: "Duncan's Lake" or 'Say "Hello"'. |
||||||||||||||||
Like | Tests that the value matches a specified string pattern. |
Enter a string pattern. Wildcards are supported using the percentage symbol (%), rather than an asterisk (*). In Automatic mode, this operator is case insensitive. This operator is not available when Mode is set to Numeric. Example: If Right Value is %bc%: abcd: Passed bc: Failed |
||||||||||||||||
Contains | Tests that the Right Value occurs somewhere in the Left Value. |
Enter a value to test for. In Automatic mode, this operator is case insensitive. This operator is not available in Numeric mode. Example: If Right Value is bc: abcd: Passed abde: Failed |
||||||||||||||||
Begins With | Tests that the Left Value string begins with the Right Value string. |
Enter the string to be tested against. In Automatic mode, this operator is case insensitive. This operator is not available in Numeric mode. Example: If Right Value is Do: Dogs: Passed Cats: Failed |
||||||||||||||||
Ends With | Tests that the Left Value string ends with the Right Value string. |
Enter the string to be tested against. In Automatic mode, this operator is case insensitive. This operator is not available in Numeric mode. Example: If Right Value is gs: Dogs: Passed Cats: Failed |
||||||||||||||||
Contains Regex | Tests that the value contains a string that matches a pattern described by a Regular Expression. |
Enter a Regular Expression. The Regular Expression Editor is available via the ellipsis (...) button, and may be used to construct and test expressions. The regex to test may represent a string to be found anywhere within the value, or may represent the entire value (by creating a regex long enough to represent the extent of the desired value). Example: If regex is \d (Any digit) cats: Failed 9: Passed cats82: Passed |
||||||||||||||||
Type Is |
Tests if the value is compatible with the chosen Type. You may test for multiple types by adding additional Test Clauses. |
Select the Type to test for.
|
||||||||||||||||
Encodable In | Tests if the value is encodable in the specified encoding without data loss. |
Select from a list of standard encodings. Sample encodings:
|
||||||||||||||||
Attribute has a value | Tests that the attribute has a value, and is not null, missing, or empty. | <Unused> | ||||||||||||||||
Attribute Is Null | Tests that the attribute has a null value. |
<Unused> |
||||||||||||||||
Attribute is Empty String | Tests that the value is an empty string. | <Unused> | ||||||||||||||||
Attribute is Missing | Tests that the attribute is absent on the feature | <Unused> |
Cached Values and Data-Aware Test Clauses
If Feature Caching is enabled, valid attribute values from upstream features can be viewed to complete test clauses.
As shown here in the Tester, if the Left Value has been set to an Attribute Value and the features have been cached, the context menu provides access to the values available in those features. If there are only a few choices, they will be presented in a sub-menu.
If there are a large number of choices, the values will be presented in a Select Value dialog, where the values may be sorted and searched with the Filter option.
Connecting Test Clauses: Logic
Multiple test clauses are connected with Logic, using AND, OR, and NOT in addition to parentheses to specify how the tests are evaluated to determine passing or failing.
Logic connectors can be edited by selecting options in the Logic column of the Test Clauses table, or may be edited directly using the Composite Expression parameter’s Edit button.
Examples
In this example, we start with a dataset of food trucks, and want to identify any records that are missing a Business Name.
The features are routed into a Tester.
In the parameters dialog, we configure one test. The Left Value is set to the BUSINESS_NAME attribute, and the Operator is set to Attribute has a value.
As there is only one test, the Pass Criteria (AND/OR/Composite) is not relevant.
No Right Value is required, as the test is simply looking for the existence of any value.
Features that fail the test are output via the Failed port, and can be sent for further processing elsewhere.
In this example, we start with a dataset of food trucks, and wish to test for those that are serving Mexican food. The features are routed into a Tester.
In the parameters dialog, we construct two tests, both using the DESCRIPTION attribute as the Left Value.
The first test looks for an exact match - any feature where the DESCRIPTION is Mexican Cuisine. The second test is less strict - it looks for any values that begin with Tacos.
The Logic connector is set OR - meaning any feature that matches either of these tests will be output via the Passed port.
Comparison Mode is set to Case Insensitive, which will apply to both test clauses.
Four features match at least one of the tests.
In this example, we start with a dataset of city parks. We will test them to find dog parks of a certain minimum size, in two specific neighborhoods. The features are routed into a Tester.
In the parameters dialog, we add four individual test clauses:
- Dog Park: Y
- Area is greater than 40000 ( square meters, in ground units - using the @Area() function to evaluate the geometry)
- Neighborhood Name is Strathcona
- Neighborhood Name is Fairview
As we have two choices of neighborhood name, we use a Composite Expression to describe the test conditions we want:
- 1 AND 2 AND (3 OR 4) means (note that the numbers indicate the row number of the test clause):
- It must be a dog park (rule 1), AND;
- It must be greater than 40,000 m2 (rule 2), AND;
- It must be in either the Strathcona (rule 3) OR Fairview (rule 4) neighborhood.
The Logic connectors and parentheses can be selected in the Logic column, or entered directly using the Edit button.
Two parks meet the criteria.
Usage Notes
- Due to bulk mode processing, features may appear to output in chunks. Although feature order from a single output port remains intact, when chunks of features are output through both the Passed and Failed ports, unexpected results may occur in workspaces that rely on feature ordering from joined output ports. In these scenarios, we recommend that you do not upgrade the Tester to its 2019.1 or later version, or revise your workspaces so they do not rely on feature ordering from joined output ports. Feature ordering may be specified with the Advanced > Preserve Feature Order parameter.
- If you have several Tester transformers in sequence, consider using the TestFilter instead. This transformer allows you to create a series of tests with named output ports for each result.
- When filtering out a subset of features, consider the logic of the test(s) when choosing an output port. For example, to remove all of the Dog Parks from a list of parks, you could either:
- Set DogParks=Y, and connect the Failed port (dropping the Passed features), or
- Set DogParks=N, and connect the Passed port (dropping the Failed features).
Configuration
Input Ports
Features to be tested.
Output Ports
If the feature passes according to the test configuration, it is output via the Passed port.
If the feature fails according to the test configuration, the feature is output via the Failed port.
Parameters
See Creating Test Clauses above for further detail.
Logic |
Determines how clauses are evaluated in a composite test. Note that changes made using the Composite Expression parameter’s Edit function will be reflected in this column once they have been Applied, including the placement of parentheses.
|
||||||||||||
Left Value |
The Left Value may be the value of an attribute, expression, a literal constant, a published parameter or a calculated value that is a combination of the above. If it is a calculated function or expression, it will be executed for each feature and the result will be used for the test. |
||||||||||||
Operator |
Select the type of test to be performed. Options include:
|
||||||||||||
Right Value |
Enter any required comparison values or supplementary configuration information for the test selected. Depending on the Operator chosen, a drop-down list of choices or an ellipses button accessing an additional dialog with correct parameters may become available, to assist in entering values. |
||||||||||||
Mode |
If required, specify a method for evaluating values. This column is only available when Comparison Mode is set to Specify Per Test. See Comparison Mode below for available options. |
||||||||||||
Comparison Mode |
Specify a method for evaluating values. This choice will be applied to all tests, unless Specify Per Test is selected, enabling the Mode column in the Test Clauses table.
Tip: If you know your data is string data, you should set the mode to either Case Sensitive or Case Insensitive. This way, FME does not spend time for each feature to determine if the data is representable as a number, but can just do the string comparison immediately. |
||||||||||||
Composite Expression |
Enabled when multiple test clauses are created. Enter or edit a test expression that defines the criteria to met in order for a feature to be considered Passed. If edits are made here, the changes will be reflected in the Test Clauses table’s Logic column once the Apply button is used to save changes. Inversely, changes made by selecting Logic options will be reflected here. Test Clauses are referred to by their number, in the order listed in the Test Clauses table. Clauses may be joined by AND, OR, and NOT, with parentheses. Example: ((1 AND 2) OR 3) Interpretation: Clause 1 AND Clause 2 must be true, OR Clause 3 must be true. See the Composite example above for a use case. |
When doing comparisons, null, missing, and empty string values, all evaluate to empty string. Thus, they are considered equal in the context of the comparison operators. Further, the following comparison ordering is respected:
- Null, missing, empty string < other values
In Automatic mode, all operators are case sensitive except Like, Contains, Begins With, and Ends With.
Preserve Feature Order |
This parameter controls the order in which features exit a transformer. When a transformer has more than one output port, features usually exit one port at a time. At times, it may be useful to keep the order that features arrived in, switching from port to port as necessary. This allows feature order to be preserved, though at a potential cost in processing efficiency. Select a method for feature ordering.
|
Editing Transformer Parameters
Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, click beside the applicable parameter. For more information, see Transformer Parameter Menu Options.
Defining Values
There are several ways to define a value for use in a Transformer. The simplest is to simply type in a value or string, which can include functions of various types such as attribute references, math and string functions, and workspace parameters. There are a number of tools and shortcuts that can assist in constructing values, generally available from the drop-down context menu adjacent to the value field.
Using the Text Editor
The Text Editor provides a convenient way to construct text strings (including regular expressions) from various data sources, such as attributes, parameters, and constants, where the result is used directly inside a parameter.
Using the Arithmetic Editor
The Arithmetic Editor provides a convenient way to construct math expressions from various data sources, such as attributes, parameters, and feature functions, where the result is used directly inside a parameter.
Conditional Values
Set values depending on one or more test conditions that either pass or fail.
Parameter Condition Definition Dialog
Content
Expressions and strings can include a number of functions, characters, parameters, and more.
When setting values - whether entered directly in a parameter or constructed using one of the editors - strings and expressions containing String, Math, Date/Time or FME Feature Functions will have those functions evaluated. Therefore, the names of these functions (in the form @<function_name>) should not be used as literal string values.
These functions manipulate and format strings. | |
Special Characters |
A set of control characters is available in the Text Editor. |
Math functions are available in both editors. | |
Date/Time Functions | Date and time functions are available in the Text Editor. |
These operators are available in the Arithmetic Editor. | |
These return primarily feature-specific values. | |
FME and workspace-specific parameters may be used. | |
Creating and Modifying User Parameters | Create your own editable parameters. |
Dialog Options - Tables
Transformers with table-style parameters have additional tools for populating and manipulating values.
Row Reordering
|
Enabled once you have clicked on a row item. Choices include:
|
Cut, Copy, and Paste
|
Enabled once you have clicked on a row item. Choices include:
Cut, copy, and paste may be used within a transformer, or between transformers. |
Filter
|
Start typing a string, and the matrix will only display rows matching those characters. Searches all columns. This only affects the display of attributes within the transformer - it does not alter which attributes are output. |
Import
|
Import populates the table with a set of new attributes read from a dataset. Specific application varies between transformers. |
Reset/Refresh
|
Generally resets the table to its initial state, and may provide additional options to remove invalid entries. Behavior varies between transformers. |
Note: Not all tools are available in all transformers.
Reference
Processing Behavior |
|
Feature Holding |
No |
Dependencies | None |
FME Licensing Level | FME Base Edition and above |
Aliases | |
History | This transformer replaced the AttributeTester and GenericTester transformers. |
FME Community
The FME Community is the place for demos, how-tos, articles, FAQs, and more. Get answers to your questions, learn from other users, and suggest, vote, and comment on new features.
Search for all results about the Tester on the FME Community.
Examples may contain information licensed under the Open Government Licence – Vancouver and/or the Open Government Licence – Canada.