Settings

Theme

Ask HN: Any suggestion on how to test CLI applications?

3 points by pdappollonio 6 years ago · 3 comments · 1 min read


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?

westurner 6 years ago

pytest-docker-pexpect: https://github.com/nvbn/pytest-docker-pexpect

Pexpect: 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

sarge.Capture.expect() takes a regex and returns None if there's no match: https://sarge.readthedocs.io/en/latest/tutorial.html#looking...

verdverm 6 years ago

https://github.com/sstephenson/bats sstephenson/bats: Bash Automated Testing System - GitHub

bryanrasmussen 6 years ago

If you like Cucumber https://github.com/cucumber/aruba

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection