Custom Tests¶
Use custom tests to check business rules that are specific to your data and that no built-in test type covers, such as an order total that must match the sum of its line items, or an end date that must not come before its start date. You write the rule in SQL, or upload a test type that packages it for reuse.
Choose a kind of custom test¶
TestGen offers four ways to define your own test. Pick the one that matches what your rule checks.
| Your rule checks | Use | Example rule |
|---|---|---|
| A condition on the columns of each record in one table | Custom Condition | Each order ships on or after its order date |
| One value computed by a query, against a minimum, a maximum, or both | SQL Metric | Fewer than 500 orders are awaiting shipment |
| Records or groups found by a query across one or more tables | Custom Test | Each order total matches the sum of its line items |
| A rule you reuse across columns and test suites, or want generated automatically | Uploaded test type Enterprise | Each value matches a proprietary identifier format |
Custom Condition is the fastest of the three SQL tests. SQL Metric and Custom Test each run their own query, and their speed depends on that query.
To add a Custom Condition, SQL Metric, or Custom Test, see Add Custom SQL Tests. To add a test type to your instance, see Upload Test Types.
How custom tests fit with other tests¶
- Test generation — You create Custom Condition, SQL Metric, and Custom Test manually, and Generate Tests does not change or remove them. An uploaded test type is generated like a built-in one when its file includes selection criteria and a generation set.
- Test results — You review, disposition, and get notified about custom test results the same way as any other test result. See Investigate Test Results.
- Quality scores — Custom Test and SQL Metric count under the Accuracy dimension, Custom Condition under Validity, and an uploaded test type under the dimension its file sets.
- Monitors — A custom test checks a fixed rule. To track a metric over time and detect anomalies against a learned range instead of fixed bounds, add a Metric monitor. See Configure Monitors.
Related topics¶
- Test Definitions — manage the tests in a test suite
- Monitor Tables — table-level anomaly detection, including custom metrics