使用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)[2022-06-27]
您也可以使用相同的Android purgeOutstandingWrites Firebase数据库客户端会自动对写入进行排队,并尽早将其发送到服务器,具体取决于网络连接。 In some cases (eg offline usage) there may be a large number of writes waiting to be sent. Calling this method will purge number of writes waiting to be sent. Calling t ... -
tl; dr:Firebase提供的setValue(_ value: Any?, andPriority priority: Any?)与使用setValue(_ value: Any?, withCompletionBlock: (Error?, FIRDatabaseReference) -> Void) 。 解决方案 :使用具有多种类型的API时,请避免使用尾随封闭。 在这种情况下,首选setValue(myValue, withCompletionBlock: { (error, dbref) i ...
-
如果没有连接,Firebase withCompletionBlock不会被调用(Firebase withCompletionBlock not called if there is no connection)[2023-01-19]
Firebase背后的想法是为您同步数据。 它不仅仅是一个简单的请求/响应系统。 因此,如果您在离线状态下执行setValue,则Firebase会保留该数据,直到您处于联机状态,然后它会在那时执行setValue(然后完成代码块将被调用)。 所以你看到的行为是预期的。 如果您只想在线时使用setValue,那么是的,您需要使用.info / connected observer。 但是,如果您尝试执行setValue或此类行的某一时刻脱机,则仍可能遇到问题。 一般来说,最好只做setValue,让Fire ... -
FreddieOh和我在Slack上聊天,问题是GoogleService-info.plist文件中列出的数据库与他正在编辑的数据库不匹配。 (看起来也许在这种情况下,他已经删除并重新创建了Firebase控制台中的项目,但未更新plist文件。) 如果您发现自己的读写访问权限设置为true并且仍然获得权限被拒绝的错误,请打开您的GoogleService-info.plist文件并查看DATABASE_URL的条目。 然后转到项目中的Firebase数据库,查看数据选项卡的顶部,并确认列出的URL与您的 ...
-
这种行为通过将Swift字符串转换为NSString来解决。 如下: customersRef.child(u.id!).child(("deals" as NSString)).childByAutoId().setValue("true") { error, dbRef in print("Is now always called") } This behaviour was fixed by casting the Swift string as N ...
-
? 如果该值在将来变为nil ,则使用。 ! 如果它在将来真的不应该变为零,则使用它,但它最初需要为零。 看问题是Swift是一种严格类型的语言,如果你声明一个变量? 你说这是类型为零。 所以字典不能告诉它存储什么类型的值.... var myVar:String? //看看myVar ,你和你的类型现在完全nil了 var myVar:String! //看看myVar ,你的值现在是nil ,但你的类型肯定是String 只需将您的代码更改为: - struct Pet { ...
-
在Swift 3中将数据添加到Firebase而不是SetValue(Add data to Firebase instead of SetValue, in Swift 3)[2022-02-11]
要解决此同时值更新, runTransactionBlocks使用runTransactionBlocks 像这个函数一样,假设这个引用是noOfPost,我想要做的就是将值增加1 如果两个用户同时增加此参考值,则此请求将上载到单独的线程中,并将覆盖数据库中同时更新的可能性: - func updateTotalNoOfPost(completionBlock : @escaping (() -> Void)){ let prntRef = FIRDatabase.database().refe ... -
如何在没有setValue的情况下获取Firebase数据库整个节点?(How to get Firebase Database whole node without setValue?)[2022-02-15]
干得好。! 希望对你有帮助。! import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.Fi ... -
在Firebase数据库中单击AlertDialog以setValue时出错(Error when clicking AlertDialog to setValue at Firebase database)[2022-04-13]
这可能与Firebase无关。 据我所知,mBTDevicesArrayList(定义和赋值未在上面显示)是一个大小为零的ArrayList,并且将值1传递给它的get方法,如错误消息“java.lang.IndexOutOfBoundsException:索引1无效,大小为0“。 堆栈跟踪中的行号将帮助您找出正在显示的三个实例中的哪一个。 This likely has nothing to do with Firebase. As far as I can tell, mBTDevicesArrayLi ... -
Firebase不接受optional类型作为值 let trimmedComment = comment?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) 尝试打开trimmedComment和todaysDate值! commentRef.setValue([ "Comment": trimmedComment!, "Date": todaysDate! ]) Firebase does no ...