[swift-users] XCTest from repl
Brian Gesiak
modocache at gmail.com
Tue Aug 9 00:05:30 CDT 2016
Lou,
Wow, this is awesome!! Excellent work.
I have a few ideas as to why you’re not actually seeing any tests run:
1. swift-corelibs-xctest expects users to run tests via the XCTMain()
function
<https://github.com/apple/swift-corelibs-xctest/blob/96144ded862f402a742345b38f8324cf108f0398/Sources/XCTest/Public/XCTestMain.swift#L52>.
I’m not sure it’s appropriate for your use case, since the function calls
exit() directly (and thus has a return type of Never). If it does fits
your use case, I’d suggest using it, since all of swift-corelibs-xctest’s
regression tests assume this function is called.
2. swift-corelibs-xctest lacks the runtime reflection used by Apple
XCTest, and so requires users to list their test methods
<https://github.com/apple/swift-corelibs-xctest/blob/1f00ab2c677d9c226dea8fa3f541999d6f4405b6/Sources/XCTest/Private/XCTestCaseSuite.swift#L31>.
I think you may see the testIt() output by adding the following:
class MyTest : XCTestCase { + static var allTests = {+
return [+ ("testIt", testIt),+ ]+ }()
override func setUp() {
Let me know if that works!
- Brian Gesiak
On Mon, Aug 8, 2016 at 3:25 PM, Lou Zell via swift-users <
swift-users at 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?
>
> Thanks,
> Lou
>
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160809/f1580285/attachment.html>
More information about the swift-users
mailing list