Watir-Webdriver:将声明未实时打印到 hudson 控制台

发布于 2024-12-14 02:53:44 字数 711 浏览 3 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮萍、无处依 2024-12-21 02:53:44

此语句可防止文本缓冲,以便立即显示 - 将其放置在脚本的顶部(对于 Cucumber,我将其放置在支持目录中的文件的顶部):

$stdout.sync = true

您是否使用任何其他框架/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):

$stdout.sync = true

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文