github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/test.md (about)

     1  # `test`
     2  
     3  > Murex's test framework - define tests, run tests and debug shell scripts
     4  
     5  ## Description
     6  
     7  `test` is used to define tests, run tests and debug Murex shell scripts.
     8  
     9  ## Usage
    10  
    11  Define an inlined test
    12  
    13  ```
    14  test define test-name { json-properties }
    15  ```
    16  
    17  Define a state report
    18  
    19  ```
    20  test state name { code block }
    21  ```
    22  
    23  Define a unit test
    24  
    25  ```
    26  test unit function|private|open|event test-name { json-properties }
    27  ```
    28  
    29  Enable or disable boolean test states (more options available in `config`)
    30  
    31  ```
    32  test config [ enable|!enable ] [ verbose|!verbose ] [ auto-report|!auto-report ]
    33  ```
    34  
    35  Disable test mode
    36  
    37  ```
    38  !test
    39  ```
    40  
    41  Execute a function with testing enabled
    42  
    43  ```
    44  test run { code-block }
    45  ```
    46  
    47  Execute unit test(s)
    48  
    49  ```
    50  test run package/module/test-name|*
    51  ```
    52  
    53  Write report
    54  
    55  ```
    56  test report
    57  ```
    58  
    59  ## Examples
    60  
    61  Inlined test
    62  
    63  ```
    64  function hello-world {
    65      test define example {
    66          "StdoutRegex": (^Hello World$)
    67      }
    68  
    69      out <test_example> "Hello Earth"
    70  }
    71  
    72  test run { hello-world }
    73  ```
    74  
    75  Unit test
    76  
    77  ```
    78  test unit function aliases {
    79      "PreBlock": ({
    80          alias ALIAS_UNIT_TEST=example param1 param2 param3
    81      }),
    82      "StdoutRegex": "([- _0-9a-zA-Z]+ => .*?\n)+",
    83      "StdoutType": "str",
    84      "PostBlock": ({
    85          !alias ALIAS_UNIT_TEST
    86      })
    87  }
    88  
    89  function aliases {
    90      # Output the aliases in human readable format
    91      runtime --aliases -> formap name alias {
    92          $name -> sprintf "%10s => ${esccli @alias}\n"
    93      } -> cast str
    94  }
    95  
    96  test run aliases
    97  ```
    98  
    99  ## Detail
   100  
   101  ### Report
   102  
   103  `test report` is only needed if `config test auto-report` is set false.
   104  However `test run` automatically enables **auto-report**.
   105  
   106  When the report is generated, be it automatically or manually triggered, it
   107  flushes the table of pending reports.
   108  
   109  ## Synonyms
   110  
   111  * `test`
   112  * `!test`
   113  
   114  
   115  ## See Also
   116  
   117  * [`<read-named-pipe>`](../parser/namedpipe.md):
   118    Reads from a Murex named pipe
   119  * [`config`](../commands/config.md):
   120    Query or define Murex runtime settings
   121  
   122  <hr/>
   123  
   124  This document was generated from [builtins/core/test/test_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/test/test_doc.yaml).