# Command

Use this assertion type to run any free command and verify its output with your expected value.

This is based on "string contains" assertions.

## Expecting

Use this type of assertion to verify against an expected output of the command.

```yaml
commands:
  - name: "NVM can switch Node version"
    command: "nvm use 14 && echo SVRUNIT: $(node -v)"
    expected: "SVRUNIT: v14."
```

## Not Expecting

Use this type if you do not want your output to show the provided value.

```yaml
commands:
  - name: "Xdebug not Corrupted"
    command: "php -v"
    not_expected: "zend_mm_heap corrupted"
```

## Expecting AND conditions

Use this type if you do not want your output to show the provided value.

```yaml
commands:
  - name: "Verify PHP 7.4 and OPcache v7.4"
    command: "php -v"
    expected_and:
      - "PHP 7.4"
      - "OPcache v7.4"
```

## Expecting OR conditions

Use this type if you do not want your output to show the provided value.

```yaml
commands
  - name: "Verify any of the allowed PHP versions"
    command: "php -v"
    expected_or:
      - "PHP 8.1"
      - "PHP 8.0"
      - "PHP 7.4"
```

## Setup / Teardown

This test also offers separate command options as setup and teardown routine.\
Commands provided with these options, will be run prior and/or after the actual command of this test.

```
commands:
  - name: "..."
    command: "...."
    expected: "..."
    setup: "mkdir -p test_assets"
    teardown: "rm -f test_assets"
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.svrunit.com/assertions/command.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
