Skip to content

Instantly share code, notes, and snippets.

View ccabanero's full-sized avatar

Clint Cabanero ccabanero

View GitHub Profile
@ccabanero
ccabanero / Sample iOS Unit Tests: Working with a ViewConroller that uses CoreLocation
Last active October 1, 2018 15:52
Sample iOS Unit Tests: Working with a ViewConroller that uses CoreLocation
import XCTest
import CoreLocation
@testable import MyProject
class ViewControllerTest: XCTestCase {
var systemUnderTest: ViewController!
override func setUp() {
@ccabanero
ccabanero / unit-test-sample-async-call-during-vc-viewdidload
Created May 6, 2016 15:57
Unit Test Sample - Confirm that an API class requests data during a ViewController's viewDidLoad
func testSUT_UsesAPIClientToRequestModelData_WhenViewLoads() {
// declare mock of APIClient
class MockAPIClient: APIClient {
var modelObjectRequested: Bool!
override func fetchDataForId(id: Int, completion: (success: Bool, object: AnyObject?, message: String?) -> ()) {
// use property to confirm the data request was made
modelObjectRequested = true
@ccabanero
ccabanero / Sample iOS Unit Tests: Testing Segue passes data to Target ViewController
Last active April 15, 2020 10:39
Sample iOS Unit Tests: Testing Segue passes data to Target ViewController
func testSUT_PassesDataToTargetViewController() {
// declare the storyboard, source view controller, and target view controller
let storyboard: UIStoryboard = UIStoryboard(name: "Main_iPhone", bundle: nil)
let callingViewController = storyboard.instantiateViewControllerWithIdentifier("PlaceListViewController") as! PlaceListViewController
let targetViewController = storyboard.instantiateViewControllerWithIdentifier("PlaceDetailsViewController") as! PlaceDetailsViewController
// fetch the segue from story board
let targetSegue: UIStoryboardSegue = UIStoryboardSegue(identifier: callingViewController.placeDetailsViewControllerSegue, source: callingViewController, destination: targetViewController)
@ccabanero
ccabanero / Sample Unit Tests: Testing UIRightBarButtonItem has correct custom UIImage when toggled
Last active October 1, 2018 15:54
Sample Unit Tests: Testing UIRightBarButtonItem has correct custom UIImage when toggled
class ViewControllerTest: XCTestCase {
var systemUnderTest: ViewController!
override func setUp() {
super.setUp()
//get the storyboard the ViewController under test is inside
let storyboard: UIStoryboard = UIStoryboard(name: "Main_iPhone", bundle: nil)
@ccabanero
ccabanero / Sample iOS Unit Tests: Working with a ViewController composed of CollectionViews
Last active August 16, 2022 03:07
Sample iOS Unit Tests: Working with a ViewController composed of CollectionViews
class ViewControllerTest: XCTestCase {
var systemUnderTest: ViewController!
override func setUp() {
super.setUp()
//get the storyboard the ViewController under test is inside
let storyboard: UIStoryboard = UIStoryboard(name: "Main_iPhone", bundle: nil)
@ccabanero
ccabanero / Sample iOS Unit Tests: Working with NavigationItems
Last active July 9, 2022 19:22
Sample iOS Unit Tests: Working with NavigationItems
// example unit tests for UIBarButtonItem target - action pattern
import XCTest
@testable import to
class ViewControllerTest: XCTestCase {
var systemUnderTest: ViewController!
override func setUp() {
@ccabanero
ccabanero / Sample iOS Unit Tests: Testing Model Class methods
Last active June 10, 2019 22:06
Sample iOS Unit Tests: Testing Model Class methods
//
// TEST CODE
import XCTest
@testable import to
class JSONReaderTest: XCTestCase {
@ccabanero
ccabanero / Sample iOS Unit Tests: Testing Model Class Initialization
Last active March 9, 2020 15:15
Sample iOS Unit Tests: Testing Model Class Initialization
// example of unit test for model initialization
// TEST CODE
import XCTest
@testable import yourmodule
class PlaceTest: XCTestCase {
@ccabanero
ccabanero / AWS CLI: Sync files from workstation to s3 bucket
Last active February 8, 2017 15:47
AWS CLI: Sync files from workstation to s3 bucket
Getting Started with AWS CLI (Command Line Interface)
1. Get your access key ID and secret access key
2. Check python (required 2.6.5+)
$ python --version
3. Download CLI via curl
$ mkdir AWSCLI
@ccabanero
ccabanero / Getting started with Mapbox Android SDK (version 3.2.0)
Last active March 11, 2016 19:46
Getting started with Mapbox Android SDK (version 3.2.0)
Description:
Steps for Getting Started with the Mapbox Android SDK (v 3.2)
1. Create a new project in Android Studio (1.5.1) (e.g. Empty Activity or Blank Activity template)
2. Installation via Gradle:
Added the following to the root ...
repositories {