ASTA Docs
User Docs
Advanced Topics
Rules

Rules

ASTA rules allow you to verify the behavior of an application based on the application state, action performed, and page contents. Rules are expressed in one or more scenarios that precisely define how the rule applies in different circumstances. The agent will automatically apply all matching active rules after each agent action (e.g., click link).

While rules embody verifications like most testing frameworks, they operate in a different manner based on inversion of control in which actions drive rules rather than rules (or scripts) driving actions. The ASTA agent is free to dynamically optimize testing based on any number of criteria, such as coverage of areas with new functionality, areas with prior issues, or areas most likely to contain issues.

Rules also use generalized selectors rather than page-specific selectors (like CSS selectors). This allows the same rule to be applied to different parts of the application without duplicating verification logic. It also makes rules less vulnerable to breakage when the application code changes.

Rules are written using an extended Gherkin Given, When, Then, Finally syntax:

  • Given context When actions Then assertions Finally assignments

Rules can be expressed in one or more scenarios that precisely define how the rule applies in different circumstances.

Impact Levels

Rules can be configured with impact levels to help prioritize test results. The impact level indicates the severity of issues found when the rule fails:

  • Critical: Issues that prevent core functionality from working
  • Serious: Issues that significantly impact user experience
  • Moderate: Issues that affect functionality but have workarounds
  • Minor: Issues that are cosmetic or have minimal impact

Impact levels are logged with test results and can be used in CI/CD quality gates and notification systems. For detailed information about impact levels, see the Impact Levels documentation.

Rule Example

Rule auth-001: Login completes successfully
  Scenario 1: When using local account
    Given page title is "Login"
	And $app.user.valid is true
	And $app.user.state is "unauthenticated"
    When action is click ~submit
    Then page is @landing-page
	And page header contains "Logout"
	Finally $app.user.state = "authenticated"

Rule Syntax

Main Structures

Rule NameDescriptionDefinition
RuleA set of scenarios that express the expected behavior of an application using the Gherkin language. The agent automatically applies matching rules during test runs, and logs the rule name and title.Rule ::= "Rule" (name | number)? ":" title Scenario+
ScenarioA named application of a rule for a specific combination of context and action.Scenario ::= "Scenario" (name | number)? ":" title RuleExp

Rule Expressions

Rule NameDescriptionDefinition
RuleExpA rule expression in extended Gherkin syntax.RuleExp ::= "Given" (Context | wildcard) "When" (Actions | wildcard) "Then" Assertions ("Finally" Assignments)?

Context

Rule NameDescriptionDefinition
ContextA conditional statement about the application state before the action specified in the scenario is performed.Context ::= (PageContextAssertion | RunContextAssertion) (Conjunction Context)?
PageContextAssertionAn assertion about the current observable page.PageContextAssertion ::= ("any" | "all")? Component property? booleanOp ("a" | "an")? ("like" | "exactly")? ValueExp
RunContextAssertionAn assertion about the application state captured in runtime variables. This can be combined with the Finally statement to test arbitrarily complex application logic and business rules.RunContextAssertion ::= runVariable booleanOp ("a" | "an")? ValueExp

Actions

Rule NameDescriptionDefinition
ActionsThe user action (performed by the agent) on the application component being tested. ASTA currently only supports one action per scenario.Actions ::= Action (Conjunction Actions)?
ActionSpecific user action in a scenario.Action ::= "action is" (InputAction | MouseAction | VisitAction | BrowserAction)

Assertions and Assignments

Rule NameDescriptionDefinition
AssertionsConditional statements about the application that are evaluated after the agent performs the action specified in the scenario. Assertions are used to test that the expected results were obtained.Assertions ::= PageContextAssertion (Conjunction Assertions)?
AssignmentsApplication state variable assignments used to capture changes to the internal application state (resulting from the specified action) for future reference in rules. Assignments are only processed if all assertions pass.Assignments ::= Assignment ("And" Assignments)?
AssignmentA state variable assignment in the format "set $var to value".Assignment ::= "set" runVariable "to" ValueExp

🔍 For expressions, argument lists, and shared command/flow syntax, see the Language Reference.