Mac Command Line Tool Swift Unit Tests

Viewed 23

I want to unit test a command line tool. I go through the following progress

Create a new project using the macOS > Command Line Tool template. Call it "MyProject"

import Foundation

class MyCode {
    func hello() {
        print("hello")
    }
}

let code = MyCode()
code.hello()

Choose File > New > Target. Select the macOS Unit Testing Bundle template. Call it "MyTests"

import XCTest
@testable import MyProject

class MyTests: XCTestCase {

    func testCode() {
        let sol = MyCode()
        sol.hello()
    }

}

Switch to test target.

Build failed.

How can I test this?

0 Answers
Related