Home / Tutorials / Advanced Constraints
Advanced Constraints¶
This tutorial covers complex constraint patterns for real-world testing scenarios.
Prerequisites¶
You should be familiar with basic constraints from the Basic Walkthrough and the Constraints reference.
Pattern 1: Nested Logic¶
Combine conditions with AND, OR, and parentheses:
IF [OS] = "Windows" AND [Architecture] = "ARM"
THEN [Browser] IN { "Edge", "Chrome" };
This says: on Windows ARM, only Edge and Chrome are available.
Pattern 2: Parameter-to-Parameter Comparisons¶
Ensure relationships between parameters:
[MinMemory] <= [MaxMemory];
[StartVersion] <> [EndVersion];
Pattern 3: Wildcard Matching¶
Use LIKE for pattern-based constraints:
IF [FileSystem] LIKE "FAT*" THEN [FileSize] <= 4096;
Matches FAT, FAT16, FAT32, etc.
Pattern 4: Set Membership¶
Use IN for multiple allowed values:
IF [OS] IN { "iOS", "Android" } THEN [DeviceType] = "Mobile";
Pattern 5: IF/THEN/ELSE¶
Handle both branches of a condition:
IF [License] = "Free"
THEN [Features] IN { "Basic", "Standard" }
ELSE [Features] IN { "Basic", "Standard", "Premium", "Enterprise" };
Pattern 6: Multiple Invariants¶
Unconditional rules that always apply:
[Priority] >= 1;
[MaxRetries] <= 10;
[Timeout] <> 0;
Numeric vs String Values¶
How you write values in constraints depends on whether the parameter is numeric or string.
A parameter is numeric if all of its values parse as numbers. Otherwise it's a string parameter.
Numeric parameter (values: 1, 2, 4, 8):
IF [RAM_GB] >= 4 THEN [Performance] = "High";
Unquoted numbers are correct here. ProTest will warn you if you use quotes on a numeric parameter.
String parameter (values: Windows, Linux, macOS):
IF [OS] = "Windows" THEN [Browser] <> "Safari";
Quoted strings are required. ProTest will flag an error if you write [OS] = Windows without quotes.
Common Mistakes¶
Watch Out
- Unquoted string values — String values must be in quotes:
[OS] = "Windows", not[OS] = Windows. ProTest's validation will catch this. - Quoted numeric values — If a parameter is all-numeric, use unquoted numbers:
[Count] > 5, not[Count] > "5". ProTest will warn you. - Conflicting constraints — If constraints make all combinations impossible, generation fails. Start simple and add constraints incrementally.
- Unknown parameter or value references — Typos in
[ParameterName]or"ValueName"are caught by validation.
Semicolons Are Optional
ProTest automatically adds missing semicolons when processing constraints. You can include them for clarity, but forgetting one won't cause an error.
Debugging Constraints¶
ProTest provides real-time validation that catches most constraint issues before you even try to generate. Check the validation summary in the left sidebar for errors and warnings.
If generation still fails:
- Comment out constraints with
#one at a time - Regenerate to find the problematic constraint
- Check for conflicts between constraints
- Use the verification framework after generation to analyze missing tuples and transitive constraints