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 shouldn't exceed.
Don't make all analyzer tests mandatory
Try to make analyzer tests mandatory only in critical cases. For example, an analyzer test for not empty/null validation can be mandatory for a mandatory attribute, while a length validation analyzer test for the same attribute can remain optional.
Avoid conflicts
You can create conflicting analyzer tests in the Developer Portal. For example, one analyzer test checks if a numeric value is greater than 100, and another one, combined with the AND operator, checks that it is less than 50. No number can be greater than 100 and less than 50 at the same time. This constitutes conflicting analyzer tests in an attribute, which causes all items to fail analyzer tests for this attribute.
To avoid conflicts, consider the combination method carefully when adding multiple analyzer tests to an attribute. Use the AND combination method for all analyzer tests that an attribute should pass in parallel, while reserving OR combinations for analyzer tests that can have variations.
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?