Best practices for adding analyzer tests
Recommendations for setting up effective and conflict-free analyzer tests.
You can use analyzer tests as you see fit, but to achieve your goals, we recommend following this simple set of best practices.
Start simple
Add basic analyzer tests first and build up to more complex validations. For example, for price values, you can start with an analyzer test checking that all values are positive numbers, and then add a limit that your prices should not exceed.
Write a clear error message and hint
Platform users see the error message and the hint in Data View when a value fails. Say what is wrong and how to fix it, for example Title is longer than 150 characters and Shorten the title in your source data or with a rule box. See Name, error message, and hint.
Avoid conflicts
A value must pass every analyzer test of its attribute, and the Developer Portal does not stop you from creating analyzer tests that cannot all pass. For example, one analyzer test checks if a numeric value is greater than 100, and another one checks that it is less than 50. No number can be greater than 100 and less than 50 at the same time, so all items fail analyzer tests for this attribute.
Before you add a second analyzer test of the same type to an attribute, check that a value can pass both.
Test, test, and test
After setting up your analyzer tests, make sure to test them with sample data to see if they work as expected. You can safely troubleshoot the setup before moving on to work with real data.
How is this guide?