AutoBE
    Preparing search index...

    Conditional statement for business rule-based test flow control.

    Enables test scenarios to branch based on runtime conditions or business rules. This should be used for genuine business logic branching where different test paths are needed based on data state or business conditions.

    IMPORTANT: For validation purposes, prefer predicate expressions instead:

    • Use IEqualPredicate instead of if (x === y) throw new Error(...)
    • Use INotEqualPredicate instead of if (x !== y) throw new Error(...)
    • Use IConditionalPredicate instead of if (!condition) throw new Error(...)
    • Use IErrorPredicate instead of if blocks that only contain error throwing

    Only use IIfStatement when:

    • Different business logic paths are needed (not just validation)
    • Complex conditional workflows that can't be expressed as simple predicates
    • Role-based or feature-flag dependent test scenarios
    • Multi-step conditional operations where predicates are insufficient

    Business scenarios requiring conditional logic:

    • Role-based test flows (premium vs regular customers)
    • Feature availability testing with different user journeys
    • Optional business process steps based on entity state
    • Complex workflow branching that involves multiple operations per branch

    AI function calling strategy: First consider if the validation can be handled by predicate expressions. Use IIfStatement only when genuine business logic branching is required that cannot be expressed through predicates.

    interface IIfStatement {
        condition: IExpression;
        elseStatement?: null | IIfStatement | IBlock;
        thenStatement: IBlock;
        type: "ifStatement";
    }
    Index

    Properties

    condition: IExpression

    Boolean expression determining which branch to execute.

    Typically evaluates business conditions like user roles, feature flags, data states, or validation results. Should represent meaningful business logic rather than arbitrary technical conditions.

    Examples:

    • Customer.role === "premium"
    • Product.status === "available"
    • Order.payment_status === "completed"
    elseStatement?: null | IIfStatement | IBlock

    Optional alternative block for when condition is false.

    Can be another IIfStatement for chained conditions (else-if) or IBlock for alternative business flow. May be null when no alternative action is needed.

    Business context: Represents fallback behavior, alternative user journeys, or error handling paths.

    thenStatement: IBlock

    Block to execute when condition is true.

    Contains the primary business flow for the conditional scenario. Should represent the main path or expected behavior when the business condition is met.

    type: "ifStatement"

    Type discriminator.