TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

3 点作者 pdappollonio超过 5 年前
Hello HN!<p>I&#x27;ve been looking at alternatives on how to test command line applications, specifically, for example, exit codes, output messages and whatnot. I&#x27;ve seen &quot;bats&quot; https:&#x2F;&#x2F;github.com&#x2F;sstephenson&#x2F;bats and Bazel for testing but I&#x27;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&#x27;s something out there that isn&#x27;t as popular but it&#x27;s useful.<p>Thoughts?

3 条评论

westurner超过 5 年前
pytest-docker-pexpect: <a href="https:&#x2F;&#x2F;github.com&#x2F;nvbn&#x2F;pytest-docker-pexpect" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nvbn&#x2F;pytest-docker-pexpect</a><p>Pexpect: <a href="https:&#x2F;&#x2F;pexpect.readthedocs.io&#x2F;en&#x2F;stable&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pexpect.readthedocs.io&#x2F;en&#x2F;stable&#x2F;</a><p>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: <a href="http:&#x2F;&#x2F;doc.pytest.org&#x2F;en&#x2F;latest&#x2F;tmpdir.html" rel="nofollow">http:&#x2F;&#x2F;doc.pytest.org&#x2F;en&#x2F;latest&#x2F;tmpdir.html</a><p>sarge.Capture.expect() takes a regex and returns None if there&#x27;s no match: <a href="https:&#x2F;&#x2F;sarge.readthedocs.io&#x2F;en&#x2F;latest&#x2F;tutorial.html#looking-for-specific-patterns-in-child-process-output" rel="nofollow">https:&#x2F;&#x2F;sarge.readthedocs.io&#x2F;en&#x2F;latest&#x2F;tutorial.html#looking...</a>
verdverm超过 5 年前
<a href="https:&#x2F;&#x2F;github.com&#x2F;sstephenson&#x2F;bats" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sstephenson&#x2F;bats</a> sstephenson&#x2F;bats: Bash Automated Testing System - GitHub
bryanrasmussen超过 5 年前
If you like Cucumber <a href="https:&#x2F;&#x2F;github.com&#x2F;cucumber&#x2F;aruba" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cucumber&#x2F;aruba</a>