我运行测试并随机发生错误:无法修改冻结的字符串(RuntimeError)
此错误似乎仅在发生超时错误后才会发生。不确定这是否意味着它们是相关的,但它让我相信。有人有什么想法导致这个?它似乎只在命令提示符下运行时发生(至少我还没有通过Rubymine看到它)。
编辑: Windows 7 64位
Ruby 1.9.3这是我正在使用的宝石:
这是堆栈跟踪:
can't modify frozen String (RuntimeError)
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/formatter/html.r
b:383:in `block in build_exception_detail'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/builder-3.0.0/lib/builder/xmlbase.rb:155:in
`call'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/builder-3.0.0/lib/builder/xmlbase.rb:155:in
`_nested_structures'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/builder-3.0.0/lib/builder/xmlbase.rb:63:in `
method_missing'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/formatter/html.r
b:373:in `build_exception_detail'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/formatter/html.r
b:269:in `exception'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:173:in `block in send_to_all'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:171:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:171:in `send_to_all'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:166:in `broadcast'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:122:in `visit_exception'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/scenario.rb:
68:in `fail!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/language_support
/language_methods.rb:117:in `rescue in invoke'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/language_support
/language_methods.rb:113:in `invoke'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/language_support
/language_methods.rb:102:in `block in execute_before'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/language_support
/language_methods.rb:101:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/language_support
/language_methods.rb:101:in `execute_before'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/language_support
/language_methods.rb:15:in `before'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/runtime/support_
code.rb:112:in `block in fire_hook'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/runtime/support_
code.rb:111:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/runtime/support_
code.rb:111:in `fire_hook'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/runtime.rb:104:i
n `before'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/background.r
b:39:in `block in accept'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/background.r
b:52:in `block in with_visitor'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/scenario.rb:
108:in `with_visitor'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/background.r
b:51:in `with_visitor'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/background.r
b:38:in `accept'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:57:in `block in visit_background'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:163:in `broadcast'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:56:in `visit_background'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/feature.rb:4
1:in `accept'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:20:in `block in visit_feature'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:163:in `broadcast'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:19:in `visit_feature'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/features.rb:
29:in `block in accept'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/features.rb:
17:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/features.rb:
17:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/features.rb:
28:in `accept'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:14:in `block in visit_features'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:163:in `broadcast'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/ast/tree_walker.
rb:13:in `visit_features'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/runtime.rb:46:in
`run!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/cli/main.rb:43:i
n `execute!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/lib/cucumber/cli/main.rb:20:i
n `execute'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/cucumber-1.1.4/bin/cucumber:14:in `<top (req
uired)>'
C:/Ruby193/bin/cucumber:19:in `load'
C:/Ruby193/bin/cucumber:19:in `<main>'
编辑2: 好的我已经跟踪了它,看起来在@browser = Watir :: Browser.new内部存在一个问题:即我在我的钩子中的命令开始阻止...不知道这里发生了什么但是我想d更新我站在哪里。
答案 0 :(得分:0)
尝试将@browser实例的创建移动到env.rb文件(在features / support中)
如果你总是需要@browser对象然后启动它可能比处理钩子更简单。
答案 1 :(得分:0)
如果您使用哈希来简化测试,或者在您调用gsub时使用哈希值!在散列中的键上,可能导致错误。不确定你当前的问题是否会发生这种情况。
我遇到了同样的错误,但情况不同。有关详细信息,请参阅Why is a string key for a hash frozen?。