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 can be combined with AND, OR, or more granularly with a Composite Test. Conditions may also be negated (testing for the opposite result).
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 certain value), a Right Value field is provided.
The Test Clauses are created in a table, and numbered sequentially.
Left Value |
Operator |
Right Value |
Negate |
Mode |
---|---|---|---|---|
The value or expression to test | The type of test to perform | The value for comparison, if required by the operator | Reverse the test results (test for the opposite condition) | Test the values in a specific manner |
Examples | ||||
Latitude | > | 49.000001 | Automatic | |
@Area() | In Range | (1,100) | Numeric | |
Type | Like | Kebabs | Case Sensitive | |
Traffic | Attribute Is Null | <Unused> | X | Automatic |
Count | Type Is | Integer | Automatic |
These are the Operators available for constructing test clauses. They may be used to test attribute values, constructed expressions, constants, and published parameters.
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 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 Note: String ranges (i.e. a-d) can also be specified. To test for values that contain a hyphen, enclose the value in quotation marks: "LL-27","LL-83" |
||||||||||||||||
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> To test for not-Null values, use the Negate option. |
||||||||||||||||
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> |
When more than one Test Clause is defined, there are three options on how a feature is classified as Passed or Failed.
Any Test (OR) |
If a feature passes ANY of the defined Test Clauses, it is considered Passed. It must fail all clauses to be considered Failed. |
All Tests (AND) |
If a feature passes ALL of the defined Test Clauses, it is considered Passed. If it fails any clause, it is considered Failed. |
Composite Test (Explicit) |
A composite test explicitly defines how the test clauses are interpreted. Each clause is numbered, and a statement can be constructed using these identifiers with parentheses and AND/OR logic connectors to define a test expression. Example: ((1 AND 2) OR 3) See the Composite example below. |
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. Note that both tests (by default) are set to Mode, Case Insensitive.
The Pass Criteria is set to Any Test (OR) - meaning any feature that matches either of these tests will be output via the Passed port.
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 test 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.
Two parks meet the criteria.
Usage Notes
- 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.
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. | ||||||||||
Negate |
A checkbox indicating that the test should return false if the test expression is true and vice versa. For example, to test for not-Null values, select Attribute is Null and Negate. Negate can be useful for isolating all-but-one (or all-but-few) values. |
||||||||||
Mode |
If required, specify a method for evaluating values.
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. |
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.
The Pass Criteria defines how multiple Test Clauses are interpreted in the final classification of the incoming feature.
Pass Criteria |
Select an option that determines how many of the defined test clauses must be successfully passed for a feature to be output via the Passed port.
|
||||||
Composite Test |
Enabled if Pass Criteria is set to Composite Test. Enter a test expression that defines the criteria to met in order for a feature to be considered Passed. Test Clauses are referred to by their number, as defined in the Test Clauses table. Clauses may be joined by AND and OR, 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. |
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 - whether entered directly in a parameter or constructed using one of the editors.
These functions manipulate and format strings. | |
A set of control characters is available in the Text Editor. | |
Math functions are available in both editors. | |
These operators are available in the Arithmetic Editor. | |
These return primarily feature-specific values. | |
FME and workspace-specific parameters may be used. | |
Working with User Parameters | Create your own editable parameters. |
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. |
Categories |
FME Knowledge Center
The FME Knowledge Center 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 Knowledge Center.
Examples may contain information licensed under the Open Government Licence – Vancouver