-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from maxwellE/testable_imports
Adds ability to add @testable import statements
- Loading branch information
Showing
9 changed files
with
143 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,4 +188,3 @@ func findImportLines(data: Data, offset: Int64?) -> [String] { | |
|
||
return [] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
Tests/TestTestableImportStatements/FixtureTestableImportStatements.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import MockoloFramework | ||
|
||
let testableImports = """ | ||
\(String.headerDoc) | ||
import Foundation | ||
/// \(String.mockAnnotation) | ||
protocol SimpleVar { | ||
var name: Int { get set } | ||
} | ||
""" | ||
|
||
let testableImportsMock = | ||
""" | ||
import Foundation | ||
@testable import SomeImport1 | ||
@testable import SomeImport2 | ||
class SimpleVarMock: SimpleVar { | ||
private var _doneInit = false | ||
init() { _doneInit = true } | ||
init(name: Int = 0) { | ||
self.name = name | ||
_doneInit = true | ||
} | ||
var nameSetCallCount = 0 | ||
var underlyingName: Int = 0 | ||
var name: Int { | ||
get { return underlyingName } | ||
set { | ||
underlyingName = newValue | ||
if _doneInit { nameSetCallCount += 1 } | ||
} | ||
} | ||
} | ||
""" | ||
|
||
let testableImportsWithOverlap = """ | ||
\(String.headerDoc) | ||
import Foundation | ||
import SomeImport1 | ||
/// \(String.mockAnnotation) | ||
protocol SimpleVar { | ||
var name: Int { get set } | ||
} | ||
""" | ||
|
||
let testableImportsWithOverlapMock = | ||
""" | ||
import Foundation | ||
@testable import SomeImport1 | ||
class SimpleVarMock: SimpleVar { | ||
private var _doneInit = false | ||
init() { _doneInit = true } | ||
init(name: Int = 0) { | ||
self.name = name | ||
_doneInit = true | ||
} | ||
var nameSetCallCount = 0 | ||
var underlyingName: Int = 0 | ||
var name: Int { | ||
get { return underlyingName } | ||
set { | ||
underlyingName = newValue | ||
if _doneInit { nameSetCallCount += 1 } | ||
} | ||
} | ||
} | ||
""" |
16 changes: 16 additions & 0 deletions
16
Tests/TestTestableImportStatements/TestableImportStatementsTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Foundation | ||
|
||
class TestableImportStatementsTests: MockoloTestCase { | ||
|
||
func testTesableImportStatements() { | ||
verify(srcContent: testableImports, | ||
dstContent: testableImportsMock, | ||
testableImports: ["SomeImport1", "SomeImport2"]) | ||
} | ||
|
||
func testTesableImportStatementsWithOverlap() { | ||
verify(srcContent: testableImportsWithOverlap, | ||
dstContent: testableImportsWithOverlapMock, | ||
testableImports: ["SomeImport1"]) | ||
} | ||
} |