跳转到主要内容

UNIX命令行工具,用于bash/shell工具单元测试

项目描述

CircleCI version

pyversions license

作者: Pahaz Blinov

仓库: https://github.com/pahaz/bashtest/

BashTest是用于测试bash/shell工具的UNIX命令行工具。

这是编写简单的bash测试的最简单方式。

要求:Python2或Python3

关键词:bash单元测试,单元测试,bash测试,sh单元测试

安装

bashtest已在PyPI上,所以只需运行

pip install bashtest

easy_install bashtest

即可将其安装到您的环境中。

从源安装时,克隆仓库并运行

python setup.py install

如果您没有pip,可以安装它

典型用例

您有一个命令行工具或bash/sh脚本,并希望对其进行测试。

例如,我们想测试ls工具。

我们需要的只是一个包含执行日志的文本文件。

./test_ls.bashtest

$ ls ./testsuit/list-directory
file1
file2.txt
file3.py
file4.sh

运行这些测试

$ bashtest test_ls.bashtest
1 items passed all tests:
   1 tests in test_ls.bashtest
1 tests in 1 items.
1 passed and 0 failed.
Test passed.

测试README示例

您有一些类似的开源项目。当然,像任何优秀的开源项目一样,您都有示例。您可以自动检查这些示例。只需在您的CI测试中添加 bashtest README.rst

更多示例

您可以在本项目中找到一些示例。请检查 test_*.bashtest 文件

变更日志

** 0.0.8 **
  • 添加 #skipbashtest 支持

** 0.0.7 **
  • 修复!移除丑陋且无用的选项

  • 新功能!测试 README.rst #4

  • 新功能!默认查找 *.bashtest #3

** 0.0.6 **
  • 修复!命令转义错误 #5

帮助

$ bashtest --help
usage: bashtest [-h] [--exitcode] [-v] [-q] [--debug] [--version]
                [file [file ...]]

BashTest is a UNIX command-line tool for running text-based bash tests.

positional arguments:
  file           Input file (by default uses *.bashtest)

optional arguments:
  -h, --help     show this help message and exit
  --exitcode     Print exitcode after command end of output
  -v, --verbose  Verbose output mode
  -q, --quiet    Silent output mode
  --debug        Print the debug information
  --version      Print the version string

项目详情


下载文件

下载适用于您的平台文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

bashtest-0.0.8.tar.gz (6.3 kB 查看哈希)

上传时间 源代码

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面