使用iTeardownMyAppFrame和iStartMyAppInAFrame在OPA5测试中重新启动应用程序超时(Restart app within OPA5 test using iTeardownMyAppFrame and iStartMyAppInAFrame timed out)
我尝试在现有的.opa.qunit.js文件中添加另一个测试,该文件需要完全重启我的应用程序。 我尝试的是在我的测试中调用“iTeardownMyAppFrame”,然后再次调用“iStartMyAppInAFrame”以确保干净的设置。
首先显示iFrame,但立即关闭,经过一段时间后,测试才会超时。 下面的两种方法都只是调用“iTeardownMyAppFrame”和“iStartMyAppInAFrame”。
opaTest("FirstTest", function(Given, When, Then) { Given.iStartTheSampleApp(); //Testlogic }); opaTest("TestWithCleanState", function(Given, When, Then) { Given.iShutdownTheApp(); //Until here everything above works fine Given.iStartTheSampleApp(); //Testlogic }); //EOF
控制台上没有错误,只有两条消息每秒重复:
sap-ui-core.js:15219 2015-03-11 10:05:37 Opa check was undefined - sap-ui-core.js:15219 2015-03-11 10:05:37 Opa is executing the check: function () { if (!bFrameLoaded) { return; } return checkForUI5ScriptLoaded(); } -
“iTeardownMyAppFrame”的预期功能是什么? 它应该仅用于在所有测试结束时拆除整个测试吗? 或者它是否也可用于重置应用程序以确保测试开始时的清洁状态? 如果是这种情况应该如何运作?
谢谢
I try to add another test to my existing .opa.qunit.js file which requires a complete restart of my app. What I tried was to call "iTeardownMyAppFrame" in my test and then again "iStartMyAppInAFrame" to ensure a clean setup.
At first the iFrame is shown but closed immediatly and after some time the test just times out. Both methods below just call "iTeardownMyAppFrame" and "iStartMyAppInAFrame" nothing else.
opaTest("FirstTest", function(Given, When, Then) { Given.iStartTheSampleApp(); //Testlogic }); opaTest("TestWithCleanState", function(Given, When, Then) { Given.iShutdownTheApp(); //Until here everything above works fine Given.iStartTheSampleApp(); //Testlogic }); //EOF
There is no error on the console, just some two messages repeating every second:
sap-ui-core.js:15219 2015-03-11 10:05:37 Opa check was undefined - sap-ui-core.js:15219 2015-03-11 10:05:37 Opa is executing the check: function () { if (!bFrameLoaded) { return; } return checkForUI5ScriptLoaded(); } -
What's the intended functionality of "iTeardownMyAppFrame"? Should it only be used to teardown the whole test at the end of all tests? Or can it also be used to reset the app to ensure a clean state at the beginning of the test? If this is the case how should it work?
Thanks
原文:https://stackoverflow.com/questions/28982464
满意答案
tl; dr:Firebase提供的
setValue(_ value: Any?, andPriority priority: Any?)
与使用setValue(_ value: Any?, withCompletionBlock: (Error?, FIRDatabaseReference) -> Void)
。解决方案 :使用具有多种类型的API时,请避免使用尾随封闭。 在这种情况下,首选
setValue(myValue, withCompletionBlock: { (error, dbref) in /* ... */ })
; 请勿setValue(myValue) { (error, dbref) in /* ... */ }
使用setValue(myValue) { (error, dbref) in /* ... */ }
。说明
这似乎是一个Swift错误。 和其他语言一样,Swift通常会选择最具体的过载。 例如,
class Alpha {} class Beta : Alpha {} class Charlie { func charlie(a: Alpha) { print("\(#function)Alpha") } func charlie(a: Beta) { print("\(#function)Beta") } } Charlie().charlie(a: Alpha()) // outputs: charlie(a:)Alpha Charlie().charlie(a: Beta() as Alpha) // outputs: charlie(a:)Alpha Charlie().charlie(a: Beta()) // outputs: charlie(a:)Beta
但是,当重载函数匹配尾随闭包时,Swift(至少有时)会选择更一般的类型。 例如,
class Foo { func foo(completion: () -> Void) { print(#function) } func foo(any: Any?) { print(#function) } } func bar() {} Foo().foo(completion: bar) // outputs: foo(completion:) Foo().foo(any: bar) // outputs: foo(any:) Foo().foo() { () in } // outputs: foo(any:) // ^---- Here lies the problem // Foo().foo(bar) will not compile; can't choose between overrides.
Any?
是比() -> Void
更普遍的类型 - 即“任何东西,甚至是空”比“接收0个参数并返回Void
类型的东西的函数”更广泛。 但是,追尾的关闭匹配Any?
; 这与您所期望的与最具体类型匹配的语言相反。tl;dr: Firebase provides a
setValue(_ value: Any?, andPriority priority: Any?)
which is incorrectly matched when using a trailing closure withsetValue(_ value: Any?, withCompletionBlock: (Error?, FIRDatabaseReference) -> Void)
.Solution: When using an API that has many varieties, avoid using trailing closures. In this case, prefer
setValue(myValue, withCompletionBlock: { (error, dbref) in /* ... */ })
; do not usesetValue(myValue) { (error, dbref) in /* ... */ }
.Explanation
This appears to be a Swift bug. As in other languages, such as Java, Swift generally chooses the most specific overload. E.g.,
class Alpha {} class Beta : Alpha {} class Charlie { func charlie(a: Alpha) { print("\(#function)Alpha") } func charlie(a: Beta) { print("\(#function)Beta") } } Charlie().charlie(a: Alpha()) // outputs: charlie(a:)Alpha Charlie().charlie(a: Beta() as Alpha) // outputs: charlie(a:)Alpha Charlie().charlie(a: Beta()) // outputs: charlie(a:)Beta
However, when overloaded functions match a trailing closure, Swift (at least, sometimes) selects the more general type. E.g.,
class Foo { func foo(completion: () -> Void) { print(#function) } func foo(any: Any?) { print(#function) } } func bar() {} Foo().foo(completion: bar) // outputs: foo(completion:) Foo().foo(any: bar) // outputs: foo(any:) Foo().foo() { () in } // outputs: foo(any:) // ^---- Here lies the problem // Foo().foo(bar) will not compile; can't choose between overrides.
Any?
is a more general type than() -> Void
-- i.e., "anything, even null" is more broad than "a function receiving 0 parameters and returning something of typeVoid
". However, the trailing closure matchesAny?
; this is the opposite of what you would expect from a language that matches the most specific type.
相关问答
更多如何为android取消firebase setValue()的意图(How to cancel firebase setValue() intentionaly for android)
Firebase Swift 3数据库在setValue withCompletionBlock上崩溃(Firebase Swift 3 Database crashes on setValue withCompletionBlock)
如果没有连接,Firebase withCompletionBlock不会被调用(Firebase withCompletionBlock not called if there is no connection)
Firebase数据库setValue:或removeValue失败:permission_denied iOS(Firebase Database setValue: or removeValue failed: permission_denied iOS)
Firebase setValue()在模拟器中工作,但不在设备上,任何人都知道为什么?(Firebase setValue() works in simulator but not on device, anyone know why? iOS 10, Swift 3.1)
Swift,Firebase:`setValue`给出错误“AnyObject不能与Dictionary Literal一起使用”(Swift, Firebase: `setValue` giving error “AnyObject cannot be used with Dictionary Literal”)
在Swift 3中将数据添加到Firebase而不是SetValue(Add data to Firebase instead of SetValue, in Swift 3)
如何在没有setValue的情况下获取Firebase数据库整个节点?(How to get Firebase Database whole node without setValue?)
在Firebase数据库中单击AlertDialog以setValue时出错(Error when clicking AlertDialog to setValue at Firebase database)
Firebase setValue无法在IOS 10,Swift 3中运行(Firebase setValue not working in IOS 10, Swift 3)
相关文章
更多Hadoop 0.21如何运行单个test case
在main方法中开启线程与@Test中开启线程
手机app
微信Web APP应用
APP运营推广
App与微信WebAPP
《测试驱动开发(中文版)》(Test-driven development:by example)扫描版[PDF]
微信公众平台如何与Web App结合?
微信公众平台如何与Web App结合
微信公众平台如何与Web App结合?
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!