Created
April 9, 2019 17:40
-
-
Save Mintri1199/88383355514a858087a2f1c826fee896 to your computer and use it in GitHub Desktop.
Unit test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UnittestingTests.swift | |
// UnittestingTests | |
// | |
// Created by Jackson Ho on 4/8/19. | |
// Copyright © 2019 Jackson Ho. All rights reserved. | |
// | |
import XCTest | |
@testable import Unittesting | |
class UnittestingTests: XCTestCase { | |
override func setUp() { | |
// Put setup code here. This method is called before the invocation of each test method in the class. | |
} | |
override func tearDown() { | |
// Put teardown code here. This method is called after the invocation of each test method in the class. | |
} | |
func testExample() { | |
// This is an example of a functional test case. | |
// Use XCTAssert and related functions to verify your tests produce the correct results. | |
} | |
func testPerformanceExample() { | |
// This is an example of a performance test case. | |
self.measure { | |
// Put the code you want to measure the time of here. | |
} | |
} | |
func testTitle() { | |
let storyboard = UIStoryboard(name: "Main", bundle: nil) | |
let viewController = storyboard.instantiateInitialViewController() as! ViewController | |
_ = viewController.view | |
XCTAssertEqual("Hello Testing World", viewController.title) | |
} | |
func testPlaceholder() { | |
let storyboard = UIStoryboard(name: "Main", bundle: nil) | |
let viewController = storyboard.instantiateInitialViewController() as! ViewController | |
_ = viewController.view | |
XCTAssertEqual("Testing Placeholder", viewController.textField.placeholder) | |
} | |
func testVowelInString() { | |
let storyboard = UIStoryboard(name: "Main", bundle: nil) | |
let viewController = storyboard.instantiateInitialViewController() as! ViewController | |
_ = viewController.view | |
XCTAssertEqual(3, viewController.vowelsInAString(string: "aaa")) | |
XCTAssertEqual(1, viewController.vowelsInAString(string: "cat")) | |
XCTAssertEqual(0, viewController.vowelsInAString(string: "nht")) | |
} | |
func testTitleMaking() { | |
let storyboard = UIStoryboard(name: "Main", bundle: nil) | |
let viewController = storyboard.instantiateInitialViewController() as! ViewController | |
_ = viewController.view | |
XCTAssertEqual("High School Musical", viewController.makeTitle(string: "high school musical")) | |
XCTAssertEqual("Cat In A Hat", viewController.makeTitle(string: "cat in a hat")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment