片段评估错误

发布于 2024-12-04 17:18:21 字数 822 浏览 1 评论 0原文

有人可以告诉我“片段评估错误”是什么意思,或者我可以在哪里寻找解决方案?我有时(但并非总是)会遇到很多这样的错误(无需更改我的代码):

[error] ! Fragment evaluation error
[error]     ThrowableException: Could not initialize class code.model.Post$  (FutureTask.java:138)
[error] code.model.PostSpec$$anonfun$1$$anonfun$apply$1.apply$mcZ$sp(PostSpec.scala:68)
[error] code.model.PostSpec$$anonfun$1$$anonfun$apply$1.apply(PostSpec.scala:51)
[error] code.model.PostSpec$$anonfun$1$$anonfun$apply$1.apply(PostSpec.scala:51)

PostSpec 的第 68 行是 (specs2) 测试中引用 Post 模型伴随对象的第一行:

val test4 = Post.fixJValue(toextract4).extract[Selection]

我正在使用 Scala 2.9.0- 1.

另外:我不知道这是否重要,但 Post 是一个 net.liftweb.mongodb.record.MongoRecord 类伴随对象:

object Post extends Post with MongoMetaRecord[Post] { ... }

Can someone tell me what "Fragment evaluation error" means, or where I might look for solutions? I sometimes (but not always) get lots of these errors (without changing my code):

[error] ! Fragment evaluation error
[error]     ThrowableException: Could not initialize class code.model.Post$  (FutureTask.java:138)
[error] code.model.PostSpec$anonfun$1$anonfun$apply$1.apply$mcZ$sp(PostSpec.scala:68)
[error] code.model.PostSpec$anonfun$1$anonfun$apply$1.apply(PostSpec.scala:51)
[error] code.model.PostSpec$anonfun$1$anonfun$apply$1.apply(PostSpec.scala:51)

Line 68 of PostSpec is the first line in the (specs2) test that references the Post model companion object:

val test4 = Post.fixJValue(toextract4).extract[Selection]

I'm using Scala 2.9.0-1.

Also: I have no idea whether it matters, but Post is a net.liftweb.mongodb.record.MongoRecord class companion object:

object Post extends Post with MongoMetaRecord[Post] { ... }

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

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

发布评论

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

评论(1

青巷忧颜 2024-12-11 17:18:21

在specs2规范中,Fragments是规范的一部分。 Fragment 可以是TextExampleStep

一些片段,例如 ExampleStep 是要执行的,并且应该捕获异常,以便将它们标记为失败。但它们不会捕获ErrorAssertionError除外)。因此,如果示例抛出 OutOfMemoryError,这将被报告为片段评估错误。

其他片段(例如 Text 片段)在评估时不应抛出异常。如果这样做,您将收到相同的片段评估错误消息。

如果没有看到完整的规范,我很难说出那里发生了什么,但我怀疑您在 Example 的主体中抛出了非异常类型。但我现在的问题多于答案:

  • test4 在哪里声明?在规范主体内?在 Context 案例类中?
  • 由于错误间歇性地发生,你确定你总是有一个正确的 mongodb 上下文吗?也许您的规范示例正在同一个 mongo 数据库实例上同时执行?

In a specs2 specification, Fragments are pieces of the specification. A Fragment can be a Text, an Example, a Step.

Some fragments, like Example and Step are meant to be executed and are supposed to catch Exceptions so that they can be marked as failures. But they won't catch Errors (except AssertionErrors). So if an Example throws an OutOfMemoryError, this will be reported as a Fragment evaluation error.

Other fragments, like Text fragments are not supposed to throw exceptions when being evaluated. If they do, you will get the same Fragment evaluation error message.

Without seeing the full specification it's hard for me to say what's happening there but I suspect that you had a non-Exception type thrown in the body of an Example. But I have more questions than answers for now:

  • where is test4 declared? Inside the specification body? Inside a Context case class?
  • since errors happen intermittently, are you sure you always have a proper mongodb context? Maybe your specification examples are being executed concurrently on the same mongo db instance?
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文