片段评估错误 [英] Fragment Evaluation Error

查看:153
本文介绍了片段评估错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我片段评估错误"是什么意思,或者我可能在哪里寻找解决方案?有时候(但并非总是)(在不更改代码的情况下)会出现很多这样的错误:

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)

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

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]

我正在使用Scala 2.9.0-1.

I'm using Scala 2.9.0-1.

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

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] { ... }

推荐答案

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

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

某些片段(例如ExampleStep)应被执行,并应捕获异常,以便可以将它们标记为失败.但是它们不会捕获Error(AssertionError除外).因此,如果示例抛出OutOfMemoryError,则将其报告为片段评估错误.

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.

其他片段(例如Text片段)在被求值时不应引发异常.如果这样做,您将收到相同的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.

在没有看到完整规范的情况下,我很难说出那里发生了什么,但是我怀疑您在Example的正文中抛出了非Exception类型.但是我现在有很多问题要比答案多了:

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:

  • test4在哪里声明?在规范体内?在Context案例类中?
  • 由于错误是间歇性发生的,因此您确定始终具有正确的mongodb上下文吗?也许您的规范示例正在同一mongo数据库实例上同时执行?
  • 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?

这篇关于片段评估错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆