使用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
2024-04-25 06:04

满意答案

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 with setValue(_ 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 use setValue(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 type Void". However, the trailing closure matches Any?; 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)

您也可以使用相同的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. Call...

Firebase Swift 3数据库在setValue withCompletionBlock上崩溃(Firebase Swift 3 Database crashes on setValue withCompletionBlock)

tl; dr:Firebase提供的setValue(_ value: Any?, andPriority priority: Any?)与使用setValue(_ value: Any?, withCompletionBlock: (Error?, FIRDatabaseReference) -> Void) 。 解决方案 :使用具有多种类型的API时,请避免使用尾随封闭。 在这种情况下,首选setValue(myValue, withCompletionBlock: { (error, dbr...

如果没有连接,Firebase withCompletionBlock不会被调用(Firebase withCompletionBlock not called if there is no connection)

Firebase背后的想法是为您同步数据。 它不仅仅是一个简单的请求/响应系统。 因此,如果您在离线状态下执行setValue,则Firebase会保留该数据,直到您处于联机状态,然后它会在那时执行setValue(然后完成代码块将被调用)。 所以你看到的行为是预期的。 如果您只想在线时使用setValue,那么是的,您需要使用.info / connected observer。 但是,如果您尝试执行setValue或此类行的某一时刻脱机,则仍可能遇到问题。 一般来说,最好只做setValue,...

Firebase数据库setValue:或removeValue失败:permission_denied iOS(Firebase Database setValue: or removeValue failed: permission_denied iOS)

FreddieOh和我在Slack上聊天,问题是GoogleService-info.plist文件中列出的数据库与他正在编辑的数据库不匹配。 (看起来也许在这种情况下,他已经删除并重新创建了Firebase控制台中的项目,但未更新plist文件。) 如果您发现自己的读写访问权限设置为true并且仍然获得权限被拒绝的错误,请打开您的GoogleService-info.plist文件并查看DATABASE_URL的条目。 然后转到项目中的Firebase数据库,查看数据选项卡的顶部,并确认列出的U...

Firebase setValue()在模拟器中工作,但不在设备上,任何人都知道为什么?(Firebase setValue() works in simulator but not on device, anyone know why? iOS 10, Swift 3.1)

这种行为通过将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...

Swift,Firebase:`setValue`给出错误“AnyObject不能与Dictionary Literal一起使用”(Swift, Firebase: `setValue` giving error “AnyObject cannot be used with Dictionary Literal”)

? 如果该值在将来变为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)

要解决此同时值更新, runTransactionBlocks使用runTransactionBlocks 像这个函数一样,假设这个引用是noOfPost,我想要做的就是将值增加1 如果两个用户同时增加此参考值,则此请求将上载到单独的线程中,并将覆盖数据库中同时更新的可能性: - func updateTotalNoOfPost(completionBlock : @escaping (() -> Void)){ let prntRef = FIRDatabase.database()...

如何在没有setValue的情况下获取Firebase数据库整个节点?(How to get Firebase Database whole node without setValue?)

干得好。! 希望对你有帮助。! 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.databa...

在Firebase数据库中单击AlertDialog以setValue时出错(Error when clicking AlertDialog to setValue at Firebase database)

这可能与Firebase无关。 据我所知,mBTDevicesArrayList(定义和赋值未在上面显示)是一个大小为零的ArrayList,并且将值1传递给它的get方法,如错误消息“java.lang.IndexOutOfBoundsException:索引1无效,大小为0“。 堆栈跟踪中的行号将帮助您找出正在显示的三个实例中的哪一个。 This likely has nothing to do with Firebase. As far as I can tell, mBTDevicesAr...

Firebase setValue无法在IOS 10,Swift 3中运行(Firebase setValue not working in IOS 10, Swift 3)

Firebase不接受optional类型作为值 let trimmedComment = comment?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) 尝试打开trimmedComment和todaysDate值! commentRef.setValue([ "Comment": trimmedComment!, "Date": todaysDate! ]) Firebase do...

相关文章

更多

Hadoop 0.21如何运行单个test case

研究 Hadoop 0.21代码时,很多情况下需要运行单个test case,如果新增了功能要测试 ...

在main方法中开启线程与@Test中开启线程

用来测试线程同步问题的代码: public class SynchronizeDemo { p ...

手机app

手机app是什么? 由于iPhone、三星等智能手机的逐步流行和广泛普及,手机app这个词语开始频繁的 ...

微信Web APP应用

微信Web APP即微信公众账号,对web APP的提供者来说这是一个门槛极低,容易到达数亿真实用户且 ...

APP运营推广

我也做了 2 个月 APP 推广,觉得自己推广的很失败,匿名吐个槽,大家帮忙分析下看看我哪里做的不好。 ...

App与微信WebAPP

我的App与微信搞上了   小麦积分墙摘自网络   最近有很多开发者关心的一个问题是如何提升app的 ...

《测试驱动开发(中文版)》(Test-driven development:by example)扫描版[PDF]

中文名: 测试驱动开发(中文版) 原名: Test-driven development:by ...

微信公众平台如何与Web App结合?

Web App简而言之就是为移动平台而优化的网页,它可以表现得和原生应用一样,并且克服了原生应用一些固 ...

微信公众平台如何与Web App结合

Web App简而言之就是为移动平台而优化的网页,它可以表现得和原生应用一样,并且克服了原生应用一些固 ...

微信公众平台如何与Web App结合?

Web App简而言之就是为移动平台而优化的网页,它可以表现得和原生应用一样,并且克服了原生应用一些固 ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本