我想用函数参数和函数参数模拟方法,结合curried参数,如:
trait Secured {
def IsAuthenticated(f: AuthenticatedData => Request[AnyContent] => Result) = {
// auth code
f(AuthenticatedData.create(request))(request)
}
def IsOwnerOfTestrun(id: String)(f: Testrun => AuthenticatedData =>
Request[AnyContent] => Result) =
IsAuthenticated { authenticatedData => implicit request => {
// auth code
f(testrun)(authenticatedData)(request)
}
}
Run Code Online (Sandbox Code Playgroud)
我如何在安全特征中模拟这些方法?
我使用Play 2.1.1/Scala 2.10.0与ScalaMock 3.0.1与Specs2:
"org.scalamock" %% "scalamock-specs2-support" % "3.0.1" % "test"
Run Code Online (Sandbox Code Playgroud) 我使用以下命令在应用程序(不是模拟器)上启动我的iOS应用程序(已经安装了应用程序).
instruments \
-w c717fa22472d7b691ae5763af90e1e44244ad85a \
-t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate \
-D "/Users/mj/Desktop/apps/trace" \
LPSimpleExample-cal \
-e UIARESULTSPATH /Users/mj/Desktop/apps \
-e UIASCRIPT /Users/mj/Desktop/apps/_run_loop.js
Run Code Online (Sandbox Code Playgroud)
它正在工作的10次中有6次.如果出现错误,我会收到以下消息:
2013-10-07 16:45:51.553 instruments[9891:1207] unable to locate CFBundleIdentifier for path: LPSimpleExample-cal
2013-10-07 16:45:51.555 instruments[9891:1207] Recording cancelled : At least one target failed to launch; aborting run
Instruments Trace Error : Error Domain=com.apple.instruments Code=1 "Error Starting Recording" UserInfo=0x7faccbef8fa0 {NSLocalizedDescription=Error Starting Recording, NSLocalizedRecoverySuggestion=At least one target failed to launch; aborting run}
Instruments Trace Error : Failed to start trace.
Run Code Online (Sandbox Code Playgroud)
对我来说,看起来仪器有一个错误.我试图在不同的情况下启动应用程序超过100次,我无法分析错误模式.设备崩溃日志说:
Process: …Run Code Online (Sandbox Code Playgroud) Play 2.1(Json.format [...])中的实验性"初始化"功能仅适用于案例类(请参阅此处).如何为特征编写隐式的自定义格式.我有以下构造:
sealed trait Plan {
def id: String
def name: String
def apps: Int
def users: Int
def testruns: Int
def price: Int
def prio: Int
}
Run Code Online (Sandbox Code Playgroud)
以下是扩展特质计划的案例类.
case class Start(
id: String = "start",
name: String = "Start",
apps: Int = 1,
users: Int = 1,
testruns: Int = 10,
price: Int = 99,
prio: Int = 30) extends Plan
case class Pro(
id: String = "pro",
name: String = "Pro",
apps: Int = 2, …Run Code Online (Sandbox Code Playgroud)