I am close to getting XCTests running in the swift repl, but for some
reason my tests are never invoked. Does anyone have a suggestion or see
something wrong with the test setup?
$ xcrun swift -F
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks
import Foundation // If you're copy pasting, copy paste these
individually!// If you get a null pointer back, use perror(dlerror())
to get a description of the
errordlopen("/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/Versions/A/XCTest",
RTLD_NOW)dlopen("/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftXCTest.dylib",
RTLD_NOW)import XCTest
class MyTest : XCTestCase {
override func setUp() {
super.setUp()
print("Setting up")
} override func tearDown() {
super.tearDown() print("Tearing down")
}
func testIt() {
print("I'm never here")
XCTAssertTrue(false, "I never see this!")
} }
let suite = XCTestSuite(name: "foo")suite.addTest(MyTest())suite.run()
I see the "setting up" and "tearing down" output, but I never see the print
inside -testIt. Any ideas?
On Mon, Aug 8, 2016 at 3:25 PM, Lou Zell via swift-users < swift-users@swift.org> wrote:
Greetings,
I am close to getting XCTests running in the swift repl, but for some
reason my tests are never invoked. Does anyone have a suggestion or see
something wrong with the test setup?
$ xcrun swift -F /Applications/Xcode-beta.app/
Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks
import Foundation // If you're copy pasting, copy paste these individually!// If you get a null pointer back, use perror(dlerror()) to get a description of the errordlopen("/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/Versions/A/XCTest", RTLD_NOW)dlopen("/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftXCTest.dylib", RTLD_NOW)import XCTest
class MyTest : XCTestCase {
override func setUp() {
super.setUp()
print("Setting up")
} override func tearDown() {
super.tearDown() print("Tearing down")
}
func testIt() {
print("I'm never here")
XCTAssertTrue(false, "I never see this!")
} }
let suite = XCTestSuite(name: "foo")suite.addTest(MyTest())suite.run()
I see the "setting up" and "tearing down" output, but I never see the
print inside -testIt. Any ideas?
// MARK: -
func selectors<T: XCTestCase>(forType type: T.Type) -> [Selector] {
var selectors = [Selector]()
var count : UInt32 = 0
let methods = class_copyMethodList(type, &count)!
for i in 0..<count {
let method = methods.advanced(by: Int(i)).pointee!
selectors.append(method_getName(method)!)
}
return selectors
}
func runTests(_ types: XCTestCase.Type...) {
let suite = XCTestSuite(name: "Required")
for t in types {
let tests = selectors(forType: t).filter() {
String($0).hasPrefix("test") }
tests.map(t.init)
.forEach(suite.addTest)
}
suite.run()
}
runTests(ATest.self, BTest.self)
Lou
···
On Mon, Aug 8, 2016 at 10:05 PM, Brian Gesiak <modocache@gmail.com> wrote:
Lou,
Wow, this is awesome!! Excellent work.
I have a few ideas as to why you’re not actually seeing any tests run:
On Mon, Aug 8, 2016 at 3:25 PM, Lou Zell via swift-users < > swift-users@swift.org> wrote:
Greetings,
I am close to getting XCTests running in the swift repl, but for some
reason my tests are never invoked. Does anyone have a suggestion or see
something wrong with the test setup?
$ xcrun swift -F /Applications/Xcode-beta.app/C
ontents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks
import Foundation // If you're copy pasting, copy paste these individually!// If you get a null pointer back, use perror(dlerror()) to get a description of the errordlopen("/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/Versions/A/XCTest", RTLD_NOW)dlopen("/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftXCTest.dylib", RTLD_NOW)import XCTest
class MyTest : XCTestCase {
override func setUp() {
super.setUp()
print("Setting up")
} override func tearDown() {
super.tearDown() print("Tearing down")
}
func testIt() {
print("I'm never here")
XCTAssertTrue(false, "I never see this!")
} }
let suite = XCTestSuite(name: "foo")suite.addTest(MyTest())suite.run()
I see the "setting up" and "tearing down" output, but I never see the
print inside -testIt. Any ideas?