Skip to content

Instantly share code, notes, and snippets.

@hoang-tran
Last active July 30, 2016 18:21
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 hoang-tran/901149f12321a47569519defae21be1e to your computer and use it in GitHub Desktop.
Save hoang-tran/901149f12321a47569519defae21be1e to your computer and use it in GitHub Desktop.
import XCTest
@testable import MyAwesomeProject
class MyNativeTests: XCTestCase {
func testGunCanShootIfItHasBullets() {
// 1. Setup: create a gun with 1 bullet
let gun = Gun(bullets: 1)
// 2. Execution: shoot
gun.shoot()
// 3. Expectation: expect Gun to be out of bullet
XCTAssertTrue(gun.bullets == 0, "expect Gun to be out of bullet")
}
func testGunCannotShootIfItHasNoBullet() {
// 1. Setup: create a gun with no bullet
let gun = Gun(bullets: 0)
// 2. Execution: shoot
gun.shoot()
// 3. Expectation: expect Gun to not shoot anything
XCTAssertTrue(gun.bullets == 0, "expect the number of bullets to remain the same")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment