1# Running Tests interactively {#sec-running-nixos-tests-interactively}
2
3The test itself can be run interactively. This is particularly useful
4when developing or debugging a test:
5
6```ShellSession
7$ nix-build nixos/tests/login.nix -A driverInteractive
8$ ./result/bin/nixos-test-driver --interactive
9starting VDE switch for network 1
10>
11```
12
13You can then take any Python statement, e.g.
14
15```py
16> start_all()
17> test_script()
18> machine.succeed("touch /tmp/foo")
19> print(machine.succeed("pwd")) # Show stdout of command
20```
21
22The function `test_script` executes the entire test script and drops you
23back into the test driver command line upon its completion. This allows
24you to inspect the state of the VMs after the test (e.g. to debug the
25test script).
26
27You can re-use the VM states coming from a previous run by setting the
28`--keep-vm-state` flag.
29
30```ShellSession
31$ ./result/bin/nixos-test-driver --interactive --keep-vm-state
32```
33
34The machine state is stored in the `$TMPDIR/vm-state-machinename`
35directory.