Skip to content

Instantly share code, notes, and snippets.

View hoang-tran's full-sized avatar

Hoang Tran hoang-tran

View GitHub Profile

describe a Gun

  • describe shoot
  • describe lock
  • describe unlock

describe Gun

  • describe shoot
    • when has bullets
      • when is unlocked
      • when is locked
    • when has no bullet
  • describe lock
  • describe unlock

describe a Gun

  • describe shoot
    • when has bullets
    • when has no bullet
  • describe lock
  • describe unlock

describe Gun

  • describe shoot
    • when has bullets
      • when is unlocked
        • it can shoot
      • when is locked
        • it cannot shoot
    • when has no bullet
      • it cannot shoot
  • describe lock
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()
import Foundation
class Gun: NSObject {
var bullets = 0
init(bullets: Int) {
self.bullets = bullets
}
import XCTest
class MyNativeTests: XCTestCase {
func testSomething() {
}
}
import XCTest
class MyNativeTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {

Match

. : match any single character
* : match 0 or more times
\+ : match 1 or more times
\= : match 0 or 1 time (match optional)
\( : open group
\) : close group

Count

platform :ios, '9.0'
target 'MyAwesomeProject' do
target 'MyAwesomeProjectTests' do
inherit! :search_paths
pod 'Specta'
pod 'Expecta'
end
end