Testing / Karate Framework Interview questions
What is the difference between Karate v1's @parallel=false and v2's @lock tag?
Both exist to prevent unsafe concurrent execution of scenarios that touch shared, contended resources, but they differ sharply in granularity.
| @parallel=false (v1) | @lock (v2) |
| All-or-nothing: opts a tagged scenario out of parallel execution entirely. | Fine-grained: only serializes scenarios that share the same lock name. |
| A tagged scenario is effectively serialized against every other scenario in the run. | Unrelated scenarios (different or no lock) continue running in parallel unaffected. |
| Simple to apply, but can significantly slow down a suite if overused. | Requires naming the specific contended resource, but preserves far more parallelism. |
The practical impact shows up directly in suite runtime: a suite with several @parallel=false-tagged scenarios effectively creates a serial bottleneck touching the whole run, while the same scenarios tagged with distinct, resource-specific @lock values only block each other when they genuinely target the same resource, letting everything else in the suite keep running concurrently around them.
More Related questions...