Using compound metric tester
The compound metric tester allows you to pick an instance of a source type of a compound metric, and save at the current point in time the following:
- All the data relevant to that compound metric from the instance of the source needed to evaluate the metric, stored in a map of metric names to arrays of doubles. No other traceable information about the instance is stored.
- The current result of evaluating this metric on the instance.
This saved set of data can later be used to verify that the compound metric still evaluates to the saved result, testing to see if any basic metric functionality has changed since the saved result evaluation. For example, it would evaluate differently if the "window" function started to behave differently than previously expected and appears in the compound metric being tested.
How to use compound metric tester
- Find an instance of the desired source type of the compound metric with well-defined data.
- Call
MetricTestData.extractTestData, passing in the required metricname,source, andevalMetricSpec. This can return a fully definedMetricTestDataobject (which should be saved as seed data in the package which the metric belongs to). - This saved
MetricTestDatacan then be used to test the metric in the future usingTestApi.validateMetricTestData, which allows the user to filter on the metrics to fetch and test as a batch. Theoretically this would be used in a short jasmine test for a package with savedMetricTestData.
Relevant types
MetricTestData: Stores the data necessary for testing a compound metric. One completed instance of this Type needs to be created per compound metric. Fieldtruthstores the expected result of evaluation (taken at the time that the metric was evaluated during creation of theMetricTestDatainstance. Think of it as a snapshot at that point in time).MetricTestData.extractTestData: Extracts data needed to evaluate compound metric and the current evaluation of the metric, as described above.MetricTestData.validate: Compares the saved result (thetruth) with a fresh evaluation of the metric on the saved bindings fromMetricTestData.extractTestData. Returns 1 if these match, and 0 otherwise.MetricTestBindings: A means of storing an array of doubles in a type accepted by theanytype so that bindings in theEvalMetricSpeccan be set (currently cannot be passed in directly as an array of doubles).TestApi.validateMetricTestData: Allows user to filter on metric names by include (pass in the entire metric's name), starts with, and name includes (string appearing in the names of returned metrics). Fetches allMetricTestDatameeting this criteria, and callsMetricTestData.validateon them.
Dependencies
TestApi.validateMetricTestData exists within type TestApi.