ruby - Ruby 测试单元在测试后未显示摘要
问题描述
通常 Ruby 测试单元会在完成后显示运行的测试摘要,如下所示:
Finished in 0.117158443 seconds.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
10 tests, 10 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
298.74 tests/s, 0.00 assertions/s
这是可行的,但现在发生了一些变化,当单元测试运行时,它会显示点,然后停止。我尝试将一些测试文件重新组织到不同的目录中,并确保更改测试运行程序中的文件路径。此外,这些点与测试/断言的数量不匹配。
Loaded suite test
Started
.................$prompt> // <<-- does not put newline here.
我注意到,如果我从另一个目录运行 testrunner,将显示摘要,但它会导致测试依赖项出错。我应该能够从同一目录运行 testrunner。这是我正在使用的 testrunner 的一个示例:https ://test-unit.github.io/test-unit/en/file.how-to.html 。最后没有显示的原因是什么?
解决方案
似乎没有将test-unit.yml
文件放在与运行脚本相同的目录中可能是一个问题。
请参阅代码中的此处或您发布的该文档的同一部分。
在此处查看它的配置方式,例如:
runner: console
console_options:
color_scheme: inverted
color_schemes:
inverted:
success:
name: red
bold: true
failure:
name: green
bold: true
这部分代码文档真的很突出:
# ## Test Runners
#
# So, now you have this great test class, but you still
# need a way to run it and view any failures that occur
# during the run. There are some test runner; console test
# runner, GTK+ test runner and so on. The console test
# runner is automatically invoked for you if you require
# 'test/unit' and simply run the file. To use another
# runner simply set default test runner ID to
# Test::Unit::AutoRunner:
也许您需要在 YML 文件中指定该跑步者?
如果没有看到你如何调用你的脚本和你的目录组织,就很难判断是什么导致了这个问题,但我认为它始于它没有读取那个 yaml 文件。
如果一切都失败了,让我推荐两个很棒的 Ruby 单元测试库,如果你觉得有必要切换到更广泛使用的库:
编辑:您还可以将您的目录恢复为与以前相同的顺序,并在您Gemfile
的测试单元 gem 中硬编码为您工作的最后一个版本,例如“测试单元”:“3.4.0”。
推荐阅读
- python - 正则表达式仅在花括号之间替换模式
- scheme - 不清楚 get 过程如何在 apply-generic (SICP) 中工作
- android - Asynctask 替代方案,没有有限数量的任务
- android - 是否可以在 Android Studio 中开发 Android Studio 插件?
- python - 自定义损失问题:急切执行函数的输入不能是 keras 符号张量但发现
- firebase - Firestore 禁用来自 Web 管理控制台的写入权限
- php - 强制下载 CSV 文件的问题 | PHP
- javascript - 在按钮单击 Toast UI Image 时调用图像
- c# - 无法从扩展类中获得价值,这是为什么呢?
- ruby-on-rails - Rails:截断文本输入而不是抱怨它太大了