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 . -A nixosTests.login.driverInteractive 8$ ./result/bin/nixos-test-driver 9[...] 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 27## Reuse VM state {#sec-nixos-test-reuse-vm-state} 28 29You can re-use the VM states coming from a previous run by setting the 30`--keep-vm-state` flag. 31 32```ShellSession 33$ ./result/bin/nixos-test-driver --keep-vm-state 34``` 35 36The machine state is stored in the `$TMPDIR/vm-state-machinename` 37directory. 38 39## Interactive-only test configuration {#sec-nixos-test-interactive-configuration} 40 41The `.driverInteractive` attribute combines the regular test configuration with 42definitions from the [`interactive` submodule](#test-opt-interactive). This gives you 43a more usable, graphical, but slightly different configuration. 44 45You can add your own interactive-only test configuration by adding extra 46configuration to the [`interactive` submodule](#test-opt-interactive). 47 48To interactively run only the regular configuration, build the `<test>.driver` attribute 49instead, and call it with the flag `result/bin/nixos-test-driver --interactive`.