[swift-corelibs-dev] Swift3 rewriting for XCTest APIs

Mike Ferris mferris at apple.com
Fri Apr 15 11:55:08 CDT 2016


Swift3 rewriting for XCTest APIs

For the most part, the automatic heuristics seem to be doing the right things for Xcode’s XCTest.  We have identified a few cases where we should perhaps discuss doing a little extra. Almost everything seems like it imports reasonably according to the API guidelines (https://swift.org/documentation/api-design-guidelines/ <https://swift.org/documentation/api-design-guidelines/>). The few cases that we think need tweaking are detailed here.

These are the changes from how the API imports automatically that we are considering. I would love to hear any comments or suggestions.

addTest[Run]()

There’s a glitch in the importer that is making XCTestSuioteRun’s addTestRun: import as addTest. We’re tracking this as a bug in the importer. In the meantime, I would fix this in Xcode’s XCTest explicitly.

	Existing imported method
	XCTestSuiteRun.addTest(testRun: XCTestRun)  

	Suggested new name
	XCTestSuiteRun.addTestRun(testRun: XCTestRun)

Bound(by: vs. (boundBy:

Here, the importer just isn't smart enough to detect that the prepositional phrase that really identifies the argument is "boundBy", not "by”. We’re also tracking this as a possible thing to fix in the importer. In the meantime, I would fix this in Xcode’s XCTest explicitly.

	Existing imported method
	XCUIElementQuery.elementBound(by index: UInt) -> XCUIElement

	Suggested new name
	XCUIElementQuery.element(boundBy index: UInt) -> XCUIElement

Query "matching..."

This next little family is a bit more subtle. The first two have a noun which just restates the type, so by the guidelines we would remove them. Technically the last one's noun is a role, not a type and so what the importer is doing is correct. But it feels inconsistent if we remove the type names but leave that one alone. To make it a little more consistent, the suggestion is to move identifier inside the parens as a required label so all these related functions have the same "outside the parens" part of their names.

	Existing imported method
	XCUIElementQuery.matchingPredicate(predicate: NSPredicate) -> XCUIElementQuery
	XCUIElementQuery.matchingType(elementType: XCUIElementType, identifier: String?) -> XCUIElementQuery
	XCUIElementQuery.matchingIdentifier(identifier: String) -> XCUIElementQuery

	Suggested new name
	XCUIElementQuery.matching(predicate: NSPredicate) -> XCUIElementQuery
	XCUIElementQuery.matching(elementType: XCUIElementType, identifier: String?) -> XCUIElementQuery
	XCUIElementQuery.matching(identifier identifier: String) -> XCUIElementQuery

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20160415/9bed1f6c/attachment.html>


More information about the swift-corelibs-dev mailing list