

GitHub - fromkk/Lunch: Lunch is helper of UI Test with Swift.
source link: https://github.com/fromkk/Lunch
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md
Lunch
Lunch is helper of UI Test with Swift.
Requirements
- Swift 4.0 or later
- iOS 9 or later
Installation
Carthage
- Insert
github "fromkk/Lunch"
to yourCartfile
. - Run
carthage update
- Link your app with
Lunch.framework
inCarthage/Build
- Link your UI test target with
LunchTest.framework
inCarthage/Build
Usage
In App target adopt protocol Creatable
.
import Lunch struct Creator: Creatable { func create<T>(_ identifier: String, userInfo: [AnyHashable : Any]?) -> T? { switch identifier { case "LunchViewController": return self.lunchViewController() as? T default: return nil } } } extension Creatable { func lunchViewController() -> LunchViewController { let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main) return storyboard.instantiateInitialViewController() as! LunchViewController } }
// AppDelegate.swift import Lunch let creator = Creator() let rootViewController: UIViewController #if DEBUG if let viewController: UIViewController = Launcher(with: creator).launch() { rootViewController = viewController } else { rootViewController = creator.lunchViewController() } #else rootViewController = creator.lunchViewController() #endif window?.rootViewController = rootViewController
NOTE: If you want change rootViewController after
Run
Xcode, setLAUNCH_VIEW_CONTROLLER
key and viewController name to value inEnvironment Variables
of your scheme.
In UI Test target.
1 Add component and adopt protocol PageObjectsRepresentable
.
import XCTest import LunchTest struct LunchViewControllerPage: PageObjectsRepresentable { var app: XCUIApplication init(app: XCUIApplication) { self.app = app } var lunchLabel: XCUIElement { return self.app.staticTexts["lunchLabel"] } }
2 Add your tests and adopt protocol ViewControllerTestable
import XCTest import LunchTest class LunchViewControllerTests: XCTestCase, ViewControllerTestable { var viewControllerName: String { return "LunchViewController" } override func setUp() { super.setUp() continueAfterFailure = false } func testLunchLabel() { let launcher = Launcher(targetViewController: self) let app = launcher.launch() let page = LunchViewControllerPage(app: app) XCTAssertTrue(page.lunchLabel.exists) XCTAssertEqual(page.lunchLabel.label, "Lunch") } }
Recommend
-
63
README.md
-
11
Trust Eats Process for Lunch A set of individuals can become a self-actualized team that can deliver working software despite uncertainty, not when they hav...
-
7
There's No Such Thing as Free Lunch: How to Choose the Best Fundraising Option for Your New Business Before charging ahead with fundraising, think carefully about how different pathways can accelerate your co...
-
7
Lunch på restaurang Platinis May 25, 2011 För mig har alltid restaurang Platinis på Hornsgatan vid Zinkensdamm varit en sunkkrog och inte en speciellt skoj sådan. Men nån gång det senaste året har de fräschat upp lokale...
-
9
Staffing numbers always seem to forget about lunch I have a rant about the realities of understaffing a support organization. This is mostly about what happens down at the very bottom level where you're dealing with one, two, thr...
-
8
Six Meetings Before Lunch · Alex Gaynor Alex Gaynor Hi, I'm Alex. I've been CISO at...
-
10
Lunch is Just a Time Offset Nov 14, 2005 • {"login"=>"fuzzyblog", "email"=>"[email protected]", "display_name"=>"fuzzyblog", "first_name"=>"Scott", "last_name"=>"Johnson"} Lunch, for me,...
-
6
While iPhone 12 mini Sales Lag, the iPhone 12 Pro Is Eating Huawei’s Lunch By Jesse Hollington...
-
13
Biden warns China will 'eat our lunch' on infrastructure spendingPublished1 day agoimage copyrightGetty Imagesimage captionUS President Joe Biden has spoken with Chinese President Xi Jinping
-
7
Stimulus test helper to ensure JS is ready when test starts · GitHub Instantly share code, notes, and snippets.
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK