首页 \ 问答 \ 使用iTeardownMyAppFrame和iStartMyAppInAFrame在OPA5测试中重新启动应用程序超时(Restart app within OPA5 test using iTeardownMyAppFrame and iStartMyAppInAFrame timed out)

使用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.

相关问答

更多

相关文章

更多

最新问答

更多
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • Java中的不可变类(Immutable class in Java)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • EXCEL VBA 基础教程下载
  • RoR - 邮件中的动态主体(部分)(RoR - Dynamic body (part) in mailer)
  • 无法在Google Script中返回2D数组?(Can not return 2D Array in Google Script?)
  • JAVA环境变量的设置和对path , classpth ,java_home设置作用和目的?
  • mysql 关于分组查询、时间条件查询
  • 如何使用PowerShell匹配运算符(How to use the PowerShell match operator)
  • Effective C ++,第三版:重载const函数(Effective C++, Third edition: Overloading const function)
  • 如何用DELPHI动态建立MYSQL的数据库和表? 请示出源代码。谢谢!
  • 带有简单redis应用程序的Node.js抛出“未处理的错误”(Node.js with simple redis application throwing 'unhandled error')
  • 使用前端框架带来哪些好处,相对于使用jquery
  • Ruby将字符串($ 100.99)转换为float或BigDecimal(Ruby convert string ($100.99) to float or BigDecimal)
  • 高考完可以去做些什么?注意什么?
  • 如何声明放在main之后的类模板?(How do I declare a class template that is placed after the main?)
  • 如何使用XSLT基于兄弟姐妹对元素进行分组(How to group elements based on their siblings using XSLT)
  • 在wordpress中的所有页面的标志(Logo in all pages in wordpress)
  • R:使用rollapply对列组进行求和的问题(R: Problems using rollapply to sum groups of columns)
  • Allauth不会保存其他字段(Allauth will not save additional fields)
  • python中使用sys模块中sys.exit()好像不能退出?
  • 将Int拆分为3个字节并返回C语言(Splitting an Int to 3 bytes and back in C)
  • 在SD / MMC中启用DDR会导致问题吗?(Enabling DDR in SD/MMC causes problems? CMD 11 gives a response but the voltage switch wont complete)
  • sed没有按预期工作,从字符串中间删除特殊字符(sed not working as expected, removing special character from middle of string)
  • 如何将字符串转换为Elixir中的函数(how to convert a string to a function in Elixir)