4 ms·
Ask HN: Any suggestion on how to test CLI applications?
Hello HN!
I've been looking at alternatives on how to test command line applications, specifically, for example, exit codes, output messages and whatnot. I've seen "bats" https://github.com/sstephenson/bats and Bazel for testing but I'm curious as what other tools people use in a day to day basis. UI testing is nice with tools like Cypress.io and maybe there's something out there that isn't as popular but it's useful.
Thoughts?
- bryanrasmussen 7y agoIf you like Cucumber https://github.com/cucumber/aruba https://github.com/cucumber/aruba
- westurner 7y agopytest-docker-pexpect: https://github.com/nvbn/pytest-docker-pexpect https://github.com/nvbn/pytest-docker-pexpect Pexpect: https://pexpect.readthedocs.io/en/stable/ https://pexpect.readthedocs.io/en/stable/ pytest with subprocess.popen (or Sarge) may be sufficient for checking return codes and checking stdout and stderr output streams. Pytest has tmp_path and tmpdir fixtures that provide less test isolation than Docker containers: http://doc.pytest.org/en/latest/tmpdir.html http://doc.pytest.org/en/latest/tmpdir.html sarge.Capture.expect() takes a regex and returns None if there's no match: https://sarge.readthedocs.io/en/latest/tutorial.html#looking-for-specific-patterns-in-child-process-output https://sarge.readthedocs.io/en/latest/tutorial.html#looking...
- verdverm 7y agohttps://github.com/sstephenson/bats https://github.com/sstephenson/bats sstephenson/bats: Bash Automated Testing System - GitHub