Debugging and Testing
Rules that look correct can still produce wrong results.
This chapter teaches you how to test rules safely, diagnose unexpected output, and build confidence that a rule works before publishing it.
What you will learn
By the end of this chapter, you will be able to:
- Apply a structured debugging strategy to any failing rule
- Build a minimal test model that isolates the behaviour you want to check
- Write negative tests that confirm a rule fails when it should
- Diagnose singleton vs array issues — one of the most common silent errors
- Use a checklist to verify your test model covers the right scenarios
How this chapter is structured
Debugging Strategy
A step-by-step approach to diagnosing a rule that returns unexpected results. Start with the filter output, not the validator.
Negative Testing
Rules should not only pass when data is correct — they must also fail when data is wrong. This section explains how to write test cases that confirm failure behaviour.
Singleton vs Array Issues
JSONata behaves differently when a result is a single object versus an array of objects. This is one of the most common causes of rules that "work on the test model but fail in production".
Starter Test Model Checklist
A practical checklist for the minimal Revit model you need to test a rule reliably: elements that should pass, elements that should fail, and edge cases.
Prerequisites
Complete Writing Rules first. You should already have a working rule before you start testing it.