Skip to main content

CLI testing

SHAFT provides terminal, Docker, SSH, and file actions with the same reporting model used by browser and API tests.

Open the terminal actions reference for executable examples and result handling.

First useful command test

Use CLI actions when the product behavior depends on a process, file, Docker command, deployment script, or remote shell state. Start with a harmless local command and assert on the captured output:

SHAFT.CLI terminal = new SHAFT.CLI();
String output = terminal.performTerminalCommand("echo Hello SHAFT");

SHAFT.Validations.assertThat().object(output).contains("Hello SHAFT");

Run the test with Maven:

mvn test

The command, output, and validation status are attached to the same Allure evidence flow as the rest of the suite.

Troubleshooting

SymptomCheck
Command works locally but fails in CIUse absolute paths or set the working directory explicitly.
Docker command times outVerify Docker is running before tuning command timeout properties.
SSH command cannot connectValidate host, user, key, network route, and CI secret injection.
File assertion fails on WindowsPrefer forward slashes in Java paths; Java resolves them on Windows.