Error[8]: Undefined offset: 6, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我是快速测试的新手,目前我想尝试四项测试.我有一个从ViewController到另一个的segue(searchingForViewController).对于这个segue,我想测试这4件事: >是否存在标识符为“searchSegue”的segue? >是否会调用segue然后点击按钮搜索? > Seogle的目的地是SearchedForViewController > Segue将Sea 我是快速测试的新手,目前我想尝试四项测试.我有一个从VIEwController到另一个的segue(searchingForVIEwController).对于这个segue,我想测试这4件事:

>是否存在标识符为“searchSegue”的segue?
>是否会调用segue然后点击按钮搜索?
> SEOgle的目的地是SearchedForVIEwController
> Segue将SearchedForVC的变量“passstring”更改为“garten”吗?

我在Main.storyboard中的segue如下所示:

我的segue代码如下(工作,但未来我只想知道如何测试):

overrIDe func prepare(for segue: UIStoryboardSegue,sender: Any?) {        if segue.IDentifIEr == "searchSegue" {            guard let controller = segue.destination as? SearchedForVIEwController         else {                return            }                controller.passedString = "garten"        }    }

目前我的测试类就像是空的,看起来像这样(只是加载视图):

class VIEwControllerTests: XCTestCase {    var vc: VIEwController!    overrIDe func setUp() {        super.setUp()        let storyboard = UIStoryboard(name: "Main",bundle: Bundle.main)        vc = storyboard.instantiateVIEwController(withIDentifIEr: "test") as! VIEwController        let _ = vc.vIEw    }    func testSegueShouldExist() {        let IDentifIErs = getSegues(ofVIEwController: vc)        XCTAssertEqual(IDentifIErs.count,1,"Segue count should equal one.")        XCTAssertTrue(IDentifIErs.contains("searchSegue"),"Segue searchSegue should exist.")     }    func testSegueActionsThenPushSearchbutton() {        // code here      }    func testSegueDirectsToSearchedForVIEwController() {        // code here      }    func testSeguePassedGartenAsValuetoSearchedForVC() {        // call prepare and test after?     }}

编辑我发现了如何实现segueShouldExist.我添加了代码.它调用辅助函数:

func getSegues(ofVIEwController vIEwController: UIVIEwController) -> [String] {        let IDentifIErs = (vIEwController.value(forKey: "storyboardSegueTemplates") as? [AnyObject])?.flatMap({ 
# VIEwControllerTests.swiftvar capturedSegue: UIStoryboardSegue?extension VIEwController {    overrIDe open func prepare(for segue: UIStoryboardSegue,sender: Any?) {        prepareSearchForVC(with: segue)        capturedSegue = segue    }}class VIEwControllerTests: XCTestCase {    var vc: VIEwController!    overrIDe func setUp() {        super.setUp()        let storyboard = UIStoryboard(name: "Main",bundle: Bundle.main)        vc = storyboard.instantiateInitialVIEwController() as! VIEwController        vc.loadVIEwIfNeeded()    }    func testSegueShouldExist() {        let IDentifIErs = getSegues(ofVIEwController: vc)        XCTAssertEqual(IDentifIErs.count,"Segue searchSegue should exist.")    }    func testSegueActionsThenPushSearchbutton() {        // Can programmatically send actions to UIControl classes        vc.searchbutton.sendActions(for: .touchUpInsIDe)        // Just makes sure any segue was called        // since there is only one in this case there's no need to be more specific        XCTAssertNotNil(capturedSegue)     }    func testSegueDirectsToSearchedForVIEwController() {        vc.performSegue(withIDentifIEr: "searchSegue",sender: nil)        // Attempts to cast the captured segue        let destination = capturedSegue?.destination as? SearchedForVC        XCTAssertNotNil(destination,"Destination should be searched for controller")    }    func testSeguePassedGartenAsValuetoSearchedForVC() {        vc.performSegue(withIDentifIEr: "searchSegue",sender: nil)        let destination = capturedSegue?.destination as? SearchedForVC        XCTAssertEqual(destination?.passedString,"garten")    }    func getSegues(ofVIEwController vIEwController: UIVIEwController) -> [String] {        let IDentifIErs = (vIEwController.value(forKey: "storyboardSegueTemplates") as? [AnyObject])?.flatMap({ 
overrIDe func prepare(for segue: UIStoryboardSegue,sender: Any?) {    if segue.IDentifIEr == "searchSegue" {        guard let controller = segue.destination as? SearchedForVIEwController     else {            return        }            controller.passedString = "garten"    }}
.value(forKey: "IDentifIEr") as? String }) ?? [] return IDentifIErs }}
.value(forKey: "IDentifIEr") as? String }) ?? [] return IDentifIErs }
解决方法 要实现这一点,您需要重新调整代码.

overrIDe func prepare(for segue: UIStoryboardSegue,sender: Any?) {    prepareSearchForVC(with: segue)}func prepareSearchForVC(with segue: UIStoryboardSegue) {    if segue.IDentifIEr == "searchSegue" {        guard let controller = segue.destination as? SearchedForVC            else {                return        }        controller.passedString = "garten"    }}

这项工作的原因是改变了VIEwController中的prepare(for:,sender :)方法:

[+++]

至:

[+++]

希望有所帮助.

总结

以上是内存溢出为你收集整理的Swift:测试Segue是否存在,有正确的目的地并改变正确的东西全部内容,希望文章能够帮你解决Swift:测试Segue是否存在,有正确的目的地并改变正确的东西所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 7, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我是快速测试的新手,目前我想尝试四项测试.我有一个从ViewController到另一个的segue(searchingForViewController).对于这个segue,我想测试这4件事: >是否存在标识符为“searchSegue”的segue? >是否会调用segue然后点击按钮搜索? > Seogle的目的地是SearchedForViewController > Segue将Sea 我是快速测试的新手,目前我想尝试四项测试.我有一个从VIEwController到另一个的segue(searchingForVIEwController).对于这个segue,我想测试这4件事:

>是否存在标识符为“searchSegue”的segue?
>是否会调用segue然后点击按钮搜索?
> SEOgle的目的地是SearchedForVIEwController
> Segue将SearchedForVC的变量“passstring”更改为“garten”吗?

我在Main.storyboard中的segue如下所示:

我的segue代码如下(工作,但未来我只想知道如何测试):

overrIDe func prepare(for segue: UIStoryboardSegue,sender: Any?) {        if segue.IDentifIEr == "searchSegue" {            guard let controller = segue.destination as? SearchedForVIEwController         else {                return            }                controller.passedString = "garten"        }    }

目前我的测试类就像是空的,看起来像这样(只是加载视图):

class VIEwControllerTests: XCTestCase {    var vc: VIEwController!    overrIDe func setUp() {        super.setUp()        let storyboard = UIStoryboard(name: "Main",bundle: Bundle.main)        vc = storyboard.instantiateVIEwController(withIDentifIEr: "test") as! VIEwController        let _ = vc.vIEw    }    func testSegueShouldExist() {        let IDentifIErs = getSegues(ofVIEwController: vc)        XCTAssertEqual(IDentifIErs.count,1,"Segue count should equal one.")        XCTAssertTrue(IDentifIErs.contains("searchSegue"),"Segue searchSegue should exist.")     }    func testSegueActionsThenPushSearchbutton() {        // code here      }    func testSegueDirectsToSearchedForVIEwController() {        // code here      }    func testSeguePassedGartenAsValuetoSearchedForVC() {        // call prepare and test after?     }}

编辑我发现了如何实现segueShouldExist.我添加了代码.它调用辅助函数:

func getSegues(ofVIEwController vIEwController: UIVIEwController) -> [String] {        let IDentifIErs = (vIEwController.value(forKey: "storyboardSegueTemplates") as? [AnyObject])?.flatMap({ 
# VIEwControllerTests.swiftvar capturedSegue: UIStoryboardSegue?extension VIEwController {    overrIDe open func prepare(for segue: UIStoryboardSegue,sender: Any?) {        prepareSearchForVC(with: segue)        capturedSegue = segue    }}class VIEwControllerTests: XCTestCase {    var vc: VIEwController!    overrIDe func setUp() {        super.setUp()        let storyboard = UIStoryboard(name: "Main",bundle: Bundle.main)        vc = storyboard.instantiateInitialVIEwController() as! VIEwController        vc.loadVIEwIfNeeded()    }    func testSegueShouldExist() {        let IDentifIErs = getSegues(ofVIEwController: vc)        XCTAssertEqual(IDentifIErs.count,"Segue searchSegue should exist.")    }    func testSegueActionsThenPushSearchbutton() {        // Can programmatically send actions to UIControl classes        vc.searchbutton.sendActions(for: .touchUpInsIDe)        // Just makes sure any segue was called        // since there is only one in this case there's no need to be more specific        XCTAssertNotNil(capturedSegue)     }    func testSegueDirectsToSearchedForVIEwController() {        vc.performSegue(withIDentifIEr: "searchSegue",sender: nil)        // Attempts to cast the captured segue        let destination = capturedSegue?.destination as? SearchedForVC        XCTAssertNotNil(destination,"Destination should be searched for controller")    }    func testSeguePassedGartenAsValuetoSearchedForVC() {        vc.performSegue(withIDentifIEr: "searchSegue",sender: nil)        let destination = capturedSegue?.destination as? SearchedForVC        XCTAssertEqual(destination?.passedString,"garten")    }    func getSegues(ofVIEwController vIEwController: UIVIEwController) -> [String] {        let IDentifIErs = (vIEwController.value(forKey: "storyboardSegueTemplates") as? [AnyObject])?.flatMap({ 
overrIDe func prepare(for segue: UIStoryboardSegue,sender: Any?) {    if segue.IDentifIEr == "searchSegue" {        guard let controller = segue.destination as? SearchedForVIEwController     else {            return        }            controller.passedString = "garten"    }}
.value(forKey: "IDentifIEr") as? String }) ?? [] return IDentifIErs }}
.value(forKey: "IDentifIEr") as? String }) ?? [] return IDentifIErs }
解决方法 要实现这一点,您需要重新调整代码.

overrIDe func prepare(for segue: UIStoryboardSegue,sender: Any?) {    prepareSearchForVC(with: segue)}func prepareSearchForVC(with segue: UIStoryboardSegue) {    if segue.IDentifIEr == "searchSegue" {        guard let controller = segue.destination as? SearchedForVC            else {                return        }        controller.passedString = "garten"    }}

这项工作的原因是改变了VIEwController中的prepare(for:,sender :)方法:

至:

[+++]

希望有所帮助.

总结

以上是内存溢出为你收集整理的Swift:测试Segue是否存在,有正确的目的地并改变正确的东西全部内容,希望文章能够帮你解决Swift:测试Segue是否存在,有正确的目的地并改变正确的东西所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Swift:测试Segue是否存在,有正确的目的地并改变正确的东西_app_内存溢出

Swift:测试Segue是否存在,有正确的目的地并改变正确的东西

Swift:测试Segue是否存在,有正确的目的地并改变正确的东西,第1张

概述我是快速测试的新手,目前我想尝试四项测试.我有一个从ViewController到另一个的segue(searchingForViewController).对于这个segue,我想测试这4件事: >是否存在标识符为“searchSegue”的segue? >是否会调用segue然后点击按钮搜索? > Seogle的目的地是SearchedForViewController > Segue将Sea 我是快速测试的新手,目前我想尝试四项测试.我有一个从VIEwController到另一个的segue(searchingForVIEwController).对于这个segue,我想测试这4件事:

>是否存在标识符为“searchSegue”的segue?
>是否会调用segue然后点击按钮搜索?
> SEOgle的目的地是SearchedForVIEwController
> Segue将SearchedForVC的变量“passstring”更改为“garten”吗?

我在Main.storyboard中的segue如下所示:

我的segue代码如下(工作,但未来我只想知道如何测试):

overrIDe func prepare(for segue: UIStoryboardSegue,sender: Any?) {        if segue.IDentifIEr == "searchSegue" {            guard let controller = segue.destination as? SearchedForVIEwController         else {                return            }                controller.passedString = "garten"        }    }

目前我的测试类就像是空的,看起来像这样(只是加载视图):

class VIEwControllerTests: XCTestCase {    var vc: VIEwController!    overrIDe func setUp() {        super.setUp()        let storyboard = UIStoryboard(name: "Main",bundle: Bundle.main)        vc = storyboard.instantiateVIEwController(withIDentifIEr: "test") as! VIEwController        let _ = vc.vIEw    }    func testSegueShouldExist() {        let IDentifIErs = getSegues(ofVIEwController: vc)        XCTAssertEqual(IDentifIErs.count,1,"Segue count should equal one.")        XCTAssertTrue(IDentifIErs.contains("searchSegue"),"Segue searchSegue should exist.")     }    func testSegueActionsThenPushSearchbutton() {        // code here      }    func testSegueDirectsToSearchedForVIEwController() {        // code here      }    func testSeguePassedGartenAsValuetoSearchedForVC() {        // call prepare and test after?     }}

编辑我发现了如何实现segueShouldExist.我添加了代码.它调用辅助函数:

func getSegues(ofVIEwController vIEwController: UIVIEwController) -> [String] {        let IDentifIErs = (vIEwController.value(forKey: "storyboardSegueTemplates") as? [AnyObject])?.flatMap({ 
# VIEwControllerTests.swiftvar capturedSegue: UIStoryboardSegue?extension VIEwController {    overrIDe open func prepare(for segue: UIStoryboardSegue,sender: Any?) {        prepareSearchForVC(with: segue)        capturedSegue = segue    }}class VIEwControllerTests: XCTestCase {    var vc: VIEwController!    overrIDe func setUp() {        super.setUp()        let storyboard = UIStoryboard(name: "Main",bundle: Bundle.main)        vc = storyboard.instantiateInitialVIEwController() as! VIEwController        vc.loadVIEwIfNeeded()    }    func testSegueShouldExist() {        let IDentifIErs = getSegues(ofVIEwController: vc)        XCTAssertEqual(IDentifIErs.count,"Segue searchSegue should exist.")    }    func testSegueActionsThenPushSearchbutton() {        // Can programmatically send actions to UIControl classes        vc.searchbutton.sendActions(for: .touchUpInsIDe)        // Just makes sure any segue was called        // since there is only one in this case there's no need to be more specific        XCTAssertNotNil(capturedSegue)     }    func testSegueDirectsToSearchedForVIEwController() {        vc.performSegue(withIDentifIEr: "searchSegue",sender: nil)        // Attempts to cast the captured segue        let destination = capturedSegue?.destination as? SearchedForVC        XCTAssertNotNil(destination,"Destination should be searched for controller")    }    func testSeguePassedGartenAsValuetoSearchedForVC() {        vc.performSegue(withIDentifIEr: "searchSegue",sender: nil)        let destination = capturedSegue?.destination as? SearchedForVC        XCTAssertEqual(destination?.passedString,"garten")    }    func getSegues(ofVIEwController vIEwController: UIVIEwController) -> [String] {        let IDentifIErs = (vIEwController.value(forKey: "storyboardSegueTemplates") as? [AnyObject])?.flatMap({ 
overrIDe func prepare(for segue: UIStoryboardSegue,sender: Any?) {    if segue.IDentifIEr == "searchSegue" {        guard let controller = segue.destination as? SearchedForVIEwController     else {            return        }            controller.passedString = "garten"    }}
.value(forKey: "IDentifIEr") as? String }) ?? [] return IDentifIErs }}
.value(forKey: "IDentifIEr") as? String }) ?? [] return IDentifIErs }
解决方法 要实现这一点,您需要重新调整代码.

overrIDe func prepare(for segue: UIStoryboardSegue,sender: Any?) {    prepareSearchForVC(with: segue)}func prepareSearchForVC(with segue: UIStoryboardSegue) {    if segue.IDentifIEr == "searchSegue" {        guard let controller = segue.destination as? SearchedForVC            else {                return        }        controller.passedString = "garten"    }}

这项工作的原因是改变了VIEwController中的prepare(for:,sender :)方法:

至:

希望有所帮助.

总结

以上是内存溢出为你收集整理的Swift:测试Segue是否存在,有正确的目的地并改变正确的东西全部内容,希望文章能够帮你解决Swift:测试Segue是否存在,有正确的目的地并改变正确的东西所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1003966.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存