堆栈跟踪的其余部分在哪里?

发布于 2024-12-08 14:12:34 字数 451 浏览 10 评论 0原文

我有一个测试引发错误。为了追查问题,我最终将此方法添加到名为 NodeAffiliation 的模型中:

def initialize a1, a2
  raise "kaboom"
end

然后我收到此错误:

RuntimeError: kaboom
app/models/node_affiliation.rb:13:in `initialize'
    test/unit/audit_test.rb:10:in `__bind_1318003437_24401'

但audit_test.rb 正在执行此操作:

Factory.create :form

不知何故,创建表单也会创建 NodeAffiliation,但这些步骤似乎在回溯。有什么想法为什么和/或如何获得它们吗?

I have a test that is raising an error. To track down the problem I ended up adding this method to a model called NodeAffiliation:

def initialize a1, a2
  raise "kaboom"
end

and then I get this error:

RuntimeError: kaboom
app/models/node_affiliation.rb:13:in `initialize'
    test/unit/audit_test.rb:10:in `__bind_1318003437_24401'

but audit_test.rb is doing this:

Factory.create :form

Somehow, creating a Form also creates a NodeAffiliation, but those steps seem to be missing in the backtrace. Any ideas why and/or how to get them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

相守太难 2024-12-15 14:12:34

测试日志可能已经有堆栈跟踪,但如果没有,您可以调用

logger.debug $!.backtrace.join("\n")

where $!是引发的异常的默认名称。这需要在救援区。我会检查您的工厂实现,它可能会将 node_affiliation 与表单对象相关联,或者可能存在一系列关系。工厂中声明的任何关联都会在创建对象时创建。

The test logs might already have the stacktrace, but if not you can call

logger.debug $!.backtrace.join("\n")

where $! is the default name of the exception that was raised. This needs to be in a rescue block. I would check your factory implementation, it is likely associating node_affiliation with form objects, or perhaps there is a chain of relations. Any associations declared in the factory get created when the object is created.

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