Shell Script Step
The Run Shell Script step executes a shell script as part of a test case — Batch, Bash or PowerShell.
When to Use
- Running setup or teardown scripts.
- Calling external tools (e.g.
curl, database CLIs, deployment tools). - File-system operations (cleanup, archive, move files).
- Triggering external processes in an integration test.
Why: Some test setup is easier (or only possible) outside the Aethrix engine — seeding infrastructure, invoking CLIs, or cleaning state. The shell step runs these with the same variable and assertion model as the rest of your suite.
Quickest Scenario
- Add a Run Shell Script step.
- Choose the Type of Shell Script:
PowerShell(cross-platform),Windows Batch(Windows only) orBash(Linux/macOS). - Type the script in the Shell Script editor. Use
${VariableName}for substitution. - Run. Standard Output and Error Output appear in the right-hand tabs.
注意
Batch can only run on Windows; Bash only on Linux/macOS; PowerShell is cross-platform. The step validates the platform before running and fails with a PlatformNotSupportedException otherwise.
Configuration
| Field | Description |
|---|---|
| Type of Shell Script | PowerShell, Windows Batch or Bash. |
| Timeout | Maximum run time of the script (default 00:02:00). The process is killed on expiry and the step fails. |
| Error output as Failed | When on, any content written to the error stream fails the step. |
| Working Directory | Fixed to the project path. |
| Shell Script | The script body (code editor). Variables are substituted before execution. |
| Script Output | Two tabs — Standard Output and Error Output (read-only). |
Parameter Reference
| Property | Description |
|---|---|
Content | The script text. Supports ${VariableName} substitution. Assertion target. |
BatchType | BatchType.PowerShell, .WindowsBatch or .Bash. |
StandardOutput | Captured stdout (DefaultAssertionTargetProperty). |
ErrorOutput | Captured error stream. |
ErrorOutputAsFailed | true (default) — fail the step if error output is non-empty. |
TimeOut | TimeSpan maximum run time (default 2 minutes). |
提示
Because StandardOutput and Content are assertion targets (AssertionStepBase), you can assert directly on the script's output — for example, assert that stdout contains healthy.
Examples
Windows (PowerShell)
Type: PowerShell
Content:
.\scripts\seed-database.ps1 -ConnectionString "${DbConnection}"
Linux / macOS (Bash)
Type: Bash
Content:
curl -s ${BaseUrl}/health | grep -q OK && echo 'healthy' > /tmp/status.txt
Cross-Platform (.NET CLI)
Type: PowerShell
Content:
dotnet test ../MyProject.Tests --filter "Category=Smoke"
Security Notes
- Commands run with the same privileges as Aethrix Studio.
- Avoid hardcoding credentials — use
${VariableName}and mark them as password parameters where possible. - In CI/CD, ensure the agent has the required interpreter/executable in
PATH.