zoukankan      html  css  js  c++  java
  • IOS UITest 初始化 ViewController

    import XCTest
    @testable import UITestDemo
    
    class UITestDemoTests: XCTestCase
    {
        
        var homevc:HomeViewController? ;
        override func setUp() {
            super.setUp()
            //
            let sb=UIStoryboard.init(name: "Main", bundle: nil);
            homevc = sb.instantiateViewControllerWithIdentifier("homeVC") as? HomeViewController;
            homevc?.loadView();//初始化viewController
            
        }
        
        override func tearDown() {
            // Put teardown code here. This method is called after the invocation of each test method in the class.
            super.tearDown()
            
        }
        
        func testExample() {
            homevc!.ClickBtnSubmit("");//触发发点击事件
            XCTAssertEqual(homevc!.tfName.text ,"y");//断言文本框内的值是y
        }
    

      主要是 下面这句. 这样就可以测试controller里的大部分逻辑了.

     homevc?.loadView();//初始化viewController
    

      

  • 相关阅读:
    ES6介绍
    django-缓存
    Python标准模块--functools
    python-深浅拷贝
    Django专题-ugettext_lazy
    PHP 连接 MySQL
    PHP 过滤器
    PHP session
    PHP cookie
    PHP 文件上传
  • 原文地址:https://www.cnblogs.com/beyoung/p/4950764.html
Copyright © 2011-2022 走看看