Skip to content

Instantly share code, notes, and snippets.

@gjones
Last active January 9, 2017 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjones/589a97e4c287a108ce88379f62772945 to your computer and use it in GitHub Desktop.
Save gjones/589a97e4c287a108ce88379f62772945 to your computer and use it in GitHub Desktop.
Simple Unit Test
// Project: ExampleTestApp
// ViewController.swift
func isNumberEven(num: Int) -> Bool {
if num %2 == 0 {
return true
} else {
return false
}
}
// ViewControllerTests.swift
import XCTest
@testable import ExampleTestApp
class ViewControllerTests: XCTestCase {
func testIsNumberEven() {
let viewController = ViewController()
let odd = 5
let even = 4
XCTAssertTrue(viewController.isNumberEven(num: even))
XCTAssertFalse(viewController.isNumberEven(num: odd))
}
// Test should pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment