UML `alt` Fragment vs Per-Message Guards for Deterministic Sequence Traces
0 reputation · 13 Feb 2021, 19:21 UTC
0 reputation · 13 Feb 2021, 19:21 UTC
Goal: generate deterministic executable traces from a UML 2.x sequence diagram for model-based testing, where each simulated run selects exactly one message path.
Constraint: an `alt` combined fragment requires exactly one operand guard to evaluate true, but an omitted otherwise case can produce no trace when every guard is false. Per-message guards avoid grouping overhead, yet UML does not standardize their expression language or evaluation order, so multiple true guards or missing tool resolution can create ambiguous traces.
Uncertainty: whether to model alternatives as an `alt` fragment with interaction constraints or as independent per-message constraints, since tool support for executing raw per-message guards in code-generation pipelines is less consistent than for `alt` simulation.
Questions:
Prefer a UML 2.x alt combined fragment with interaction constraints over per-message guards when generating deterministic executable traces. The alt fragment groups alternatives into a single conditional construct that test engines can export more reliably than scattered guards. Per-message guards lack standardized expression language and evaluation order, so multiple guards can be true simultaneously or be dropped during export. However, alt is not automatically deterministic: the simulator must select exactly one true operand, and without an otherwise operand every guard can evaluate false and produce no trace.
alt operand carries an interaction constraint; per-message guards attach to individual messages and have no standardized evaluation order.otherwise, an alt fragment can yield zero traces when all explicit guards are false.The ambiguity comes from separating the UML notation from the execution tool. alt is structurally stronger because it forces alternatives into one declared set, but the engine still decides the outcome when zero, one, or multiple operand constraints are true. OCL is more portable than a proprietary action language only if the target code generator can evaluate OCL constraints.
alt combined fragment, with one interaction constraint per operand.otherwise operand if every simulated run must emit exactly one trace; otherwise treat an all-false run as a coverage gap.alt operand carries an interaction constraint and that otherwise maps to an else branch in the target engine.otherwise, or reports an error.Does your target test execution engine evaluate alt operand constraints, or does it only support message-level guards? This determines whether OCL in an alt fragment is executable or whether you must use per-message guards in the engine's native action language.
alt operands are not automatically resolved by UML; the simulator may choose the first, choose randomly, or fail. Confirm your simulator's tie-breaking rule before relying on alt for determinism.otherwise operand can mask incomplete guard coverage and reduce fault detection.alt operand should carry an interaction constraint; otherwise should map to an else branch.otherwise selection, or error.Use comments to ask for clarification. Post a solution as an answer.
7,000 reputation · 14 Feb 2021, 04:14 UTC
An alt operand's interaction constraint is evaluated when the combined fragment is entered, not immediately before each outgoing message. If a lifeline's state changes between that decision point and message emission—such as a prior message in the same trace mutating an attribute referenced by the guard—the selected operand may no longer match the state at execution time. This is distinct from per-message guards, which are conceptually tied to individual message events. For UML 2.x simulation, verify determinism by logging each operand constraint result at fragment entry and again immediately before the first message in the chosen operand fires; if the results differ, the trace is not guard-stable. Treat this as a tool-specific verification step, since UML does not mandate re-evaluation.