Post

Replies

Boosts

Views

Activity

How do I unittest a command line application?
I am new to swift and xcode and I'm looking for instructions on how to unit test code on a command line application.I've tried to build one myself but the compiler is giving me link errors that I can't debug. If there is some tutorial I couldn't find on google please point me to it - but most of the documentation out there is for learning swift via playgrounds - but I'd like to learn using unittesting and code katas.Whenever I build I always get linker errors. Also no sort of code detection works like autocomplete for the classes I write.Undefined symbols for architecture x86_64: "Doubler.Doubler.__allocating_init () -> Doubler.Doubler", referenced from: DoublerTests.DoublerTests.testExample () -> () in DoublerTests.o "type metadata accessor for Doubler.Doubler", referenced from: DoublerTests.DoublerTests.testExample () -> () in DoublerTests.old: symbol(s) not found for architecture x86_64clang: error: linker command failed with exit code 1 (use -v to see invocation)import XCTest @testable import Doubler class DoublerTests: XCTestCase { override func setUp() { super.setUp() } override func tearDown() { super.tearDown() } func testDoubler() { let x = Doubler() XCTAssertEqual(10, x.double(3)) // this should compile but fail the test } }Doubler:import Foundation class Doubler { init (){ } func double(n: Int) -> Int { return n * 2 } }
9
1
10k
Jul ’16