r - 如何使用 shinytest 记录或跟踪?
问题描述
我希望能够看到reactive({...})
我的代码部分内部发生了什么。我认为使用 shinytest 可能是一种执行我的应用程序部分的方法,这些部分使用Shiny Modules
和了解callModule
.
我在我的代码中尝试了以下内容来记录/跟踪/打印。
print("hello1")
message("hello2")
cat(file=stderr(), "hello3")
logging::loginfo("hello4")
运行测试
library(shinytest)
testApp("/home/eddy/rwork/filters", "mytest")
viewTestDiff("/home/eddy/rwork/filters", interactive = FALSE)
输出:
Rscript runtest.R
Running mytest.R
==== Comparing mytest... No changes.
==== mytest ====
No differences between expected and current results
如何在测试运行中添加一些跟踪输出?
解决方案
我不认为现在有一种非常方便的方法可以在 shinytest 中查看应用程序输出,但是 ShinyDriver 对象上有这个方法:
app$getDebugLog()
查询一个或多个调试日志:shiny_console
,browser
或shinytest
.https://rstudio.github.io/shinytest/reference/ShinyDriver.html
您可以将此shiny_console
选项与在单个测试中打印应用程序输出的选项一起使用,例如:
# mytest.R
app <- ShinyDriver$new()
...
log <- app$getDebugLog("shiny_console")
print(log)
推荐阅读
- javascript - CSS left !important 不会覆盖之前的左侧值
- css - 使用带有动画渐变的文本阴影
- javascript - 如何按相同的值对 JSON 数据进行排序?
- python-3.x - 从目录访问文件
- android - 如何使用 ADB 将一些文本复制到 android 系统剪贴板?
- django - 通过 Heroku Github 管道部署公共 Django 项目而不公开凭据
- macos - npm run watch 在更新到 Mac OS X Mojave 后出现错误
- python - 如何获取输入 gtk.entry 字段的值并在按钮信号之外使用它
- javascript - 如何插入activeTab权限
- javascript - 在 JavaScript 中,如何在不使用正则表达式的情况下用 replace() 函数替换字符串中的多个值?