Skip to content

[swift-build] update swift build --init library tests format #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 2, 2016

Conversation

kostiakoval
Copy link
Contributor

Update test to new format. The old format doesn't work on Linux any more.

run sb --init library in NewInit folder
This genere these File:

//LinuxMain.swift

import XCTest
@testable import NewInitTestSuite

XCTMain([
     testCase(NewInit.allTests),
])

//Tests/NewInit/NewInit.swift

import XCTest
@testable import NewInit

class NewInit: XCTestCase {

    func testExample() {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
    }

}
extension NewInit {
    static var allTests : [(String, NewInit -> () throws -> Void)] {
        return [
            ("testExample", testExample),
        ]
    }
}

Notes:

The only think I don't like here that NewInit TestCase class and file has the same name as source file.
I think it would be nice to add a suffix, like: NewInitTests or NewInitTestCase

I see that in SwiftPM we use both naming conventions.

@kostiakoval kostiakoval changed the title update swift --init library tests format [swift-build] update swift build --init library tests format Mar 21, 2016
@kostiakoval
Copy link
Contributor Author

@modocache Do you have any thoughts about files and classes naming for tests?

@mxcl
Copy link
Contributor

mxcl commented Mar 22, 2016

I agree, a TestCase suffix seems like a good idea.

@kostiakoval
Copy link
Contributor Author

After thinking for some time about it, I think TestCase prefix is not a good naming.
Maybe we should discuss it in mailing-list instead.

My reasoning:

  1. It's to verbose and duplicate naming information from XCTestCase
  2. It's not consistent with Xcode tests naming. Xcode uses Tests suffix
  3. It's specific for XCTestCase. It's not generic and has not so strong meaning when using with other test framework, like Quick
  4. swift-test tool uses Test Case naming for a particular test. That's correct in my opinion.
Test Case '-[GetTestSuite.VersionGraphTests testComplexVersionRestrictedGraph]' passed (0.001 seconds).

Conclusion
I prefer Tests prefix. It's clearly says that this file and class contains test, it's more generic and consistent with existing tools. :)

@aciidgh
Copy link
Contributor

aciidgh commented Mar 23, 2016

I know executable tests are not supported right now but is it possible to somehow add a test to catch this in future?

@kostiakoval
Copy link
Contributor Author

Yes definitely! I even think I know how do that :)

  • invoke "swift build --init",
  • run build for generated project
  • run test.

But I thought it would be in next PR. This is broken on Linux so I would prefer to get it merged now

@mxcl
Copy link
Contributor

mxcl commented Mar 31, 2016

You mean a Tests suffix?

@modocache
Copy link
Contributor

The convention for XCTestCase tests has been {SubjectUnderTest}Tests. Why not generate an NewInitTests here?

@mxcl
Copy link
Contributor

mxcl commented Mar 31, 2016

The convention for XCTestCase tests has been {SubjectUnderTest}Tests. Why not generate an NewInitTests here?

Suits me.

@kostiakoval
Copy link
Contributor Author

@mxcl Done

@mxcl
Copy link
Contributor

mxcl commented Mar 31, 2016

@swift-ci Please test

@mxcl
Copy link
Contributor

mxcl commented Apr 1, 2016

LGTM

@kostiakoval kostiakoval merged commit f57a878 into swiftlang:master Apr 2, 2016
@kostiakoval kostiakoval deleted the init-lib-tests branch April 2, 2016 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants