Watir-Webdriver:将声明未实时打印到 hudson 控制台
我正在使用 watir-webdriver[ruby] 运行一些测试,并且在这些测试中我添加了一些将打印到控制台的 put 语句。在终端/命令提示符下运行时,消息会立即打印到控制台。
但是当我从 Hudson 运行相同的测试时,打印不会实时发生。相反,它会等到作业完成,最后一次转储所有打印件。
这样,我无法实时检查我的测试是否运行良好及其状态。
有什么解决办法吗?
谢谢 Sudhi
更新:
亚当, 这现在对我有用。我的代码片段如下所示。
stdout.sync = true
class TC_MyTest < Test::Unit::TestCase
$stdout.sync = true
def test_sample
$i=0
@@log.debug "Running the scenario = "+@@SCENARIO
puts "Running the scenario = "+@@SCENARIO
while $i<@@LOOPCOUNT
@@log.debug "Running the loop # "+$i.to_s
puts "Running the loop # "+$i.to_s
# Clean up the system
killOldProcesses()
end
end
end
I am running few tests using watir-webdriver[ruby], and in those tests I have added few puts statements which will print to the console. When running in terminal/command prompt, the messages are printed to the console immediately.
But when I run the same tests from Hudson, the print does not happen in real time. Instead, it will wait till the job completes and at the end it will dump all the print at one shot.
This way, I am not able to check if my tests are running fine and their status in real time.
Are there any solutions for this?
Thanks
Sudhi
Update:
Adam,
This did now work for me. My code snippet looks like this.
stdout.sync = true
class TC_MyTest < Test::Unit::TestCase
$stdout.sync = true
def test_sample
$i=0
@@log.debug "Running the scenario = "+@@SCENARIO
puts "Running the scenario = "+@@SCENARIO
while $i<@@LOOPCOUNT
@@log.debug "Running the loop # "+$i.to_s
puts "Running the loop # "+$i.to_s
# Clean up the system
killOldProcesses()
end
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此语句可防止文本缓冲,以便立即显示 - 将其放置在脚本的顶部(对于 Cucumber,我将其放置在支持目录中的文件的顶部):
您是否使用任何其他框架/gems?我遇到了 Jenkins 未实时显示 Cucumber 脚本中的 put 语句的问题。解决方案是将这些 put 语句移至我的 页面对象页面而不是步骤文件(功能 -> 步骤 -> 页面)。
使用这两种约定,我可以根据需要获得实时 Jenkins 输出。
This statement prevents buffering of text so that it displays immediately - place it at the top of your script (for Cucumber I place it at the top of a file in my support directory):
Are you using any other frameworks/gems? I had an issue with Jenkins not displaying puts statements in Cucumber scripts in real time. The solution was to move those puts statements into my Page Object pages rather than the steps files (Feature -> Steps -> Pages).
Using both of these conventions, I get real time Jenkins output as desired.