Skip to content

Commit

Permalink
fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vmzhivetyev committed Sep 5, 2023
1 parent 17a7d81 commit 7180c6b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 15 deletions.
8 changes: 8 additions & 0 deletions Sources/Swiftlane/Factories/DependenciesFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,14 @@ public enum DependenciesFactory {
)
}

DependencyResolver.shared.register(XCTestPlanFinding.self) {
XCTestPlanFinder(
filesManager: resolve(),
xctestRunFinder: resolve(),
xcTestRunParser: resolve()
)
}

DependencyResolver.shared.register(XCTestServicing.self) {
XCTestService(
xctestParser: resolve(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class ChangesCoverageLimitCheckerTests: XCTestCase {
ignoreCheckForTargetBranches: ignoredTargetBranches
),
projectDir: AbsolutePath.random(lastComponent: "projectDir"),
excludedFileNameMatchers: excludedFileNameMatchers
excludedFileNameMatchers: excludedFileNameMatchers,
slatherReportFilePath: Path.randomAbsolute()
)

checker = .init(
Expand Down Expand Up @@ -110,9 +111,7 @@ class ChangesCoverageLimitCheckerTests: XCTestCase {

slather.given(
.parseCoverageJSON(
projectDir: .value(config.projectDir),
reportFileName: "coverage.json",
outputDirPath: .value(try! Path("builds/results")),
filePath: .value(config.slatherReportFilePath.makeAbsoluteIfIsnt(relativeTo: .random())),
willReturn: slatherFileCodeCoverage
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class StubDeclarationCheckerTests: XCTestCase {
projectDir: projectDir,
mocksTargetsPath: try NSRegularExpression(pattern: "^mocks/(\\w+)", options: .anchorsMatchLines),
testsTargetsPath: try NSRegularExpression(pattern: "^tests/(\\w+)", options: .anchorsMatchLines),
ignoredFiles: [.equals("mocks/Target1/test_file_1.swift")]
ignoredFiles: [.equals("mocks/Target1/test_file_1.swift")],
testableTargetsListFilePath: try .relative(RelativePath("testableTargetsListFilePath"))
)
)

Expand Down Expand Up @@ -82,8 +83,7 @@ class StubDeclarationCheckerTests: XCTestCase {

slatherService.given(
.readTestableTargetsNames(
projectDir: .value(projectDir),
fileName: ".testable.targets.generated.txt",
filePath: .value(try! projectDir.appending(path: "testableTargetsListFilePath")),
willReturn: [
"Target1",
"Target2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class TargetsCoverageLimitCheckerTests: XCTestCase {
excludeFilesFilters: ["base": []],
targetCoverageLimits: [:],
allowedProductNameSuffixes: [".app", ".framework"],
excludeTargetsNames: [.equals("EXCLUDE_1"), .equals("EXCLUDE_2")]
excludeTargetsNames: [.equals("EXCLUDE_1"), .equals("EXCLUDE_2")],
totalCodeCoverageMessagePrefix: nil
),
projectDir: AbsolutePath.random(lastComponent: "projectDir"),
xcresultDir: AbsolutePath.random(lastComponent: "xcresultDir"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ class WarningLimitsCheckerTests: XCTestCase {
trackingNewFoldersCommitMessage: "trackingNewFoldersCommitMessage",
loweringWarningLimitsCommitMessage: "loweringWarningLimitsCommitMessage",
committeeName: "committeeName",
committeeEmail: "committeeEmail"
committeeEmail: "committeeEmail",
testableTargetsListFile: .relative(try! RelativePath("testableTargetsListFile"))
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ class WarningLimitsUntrackedCheckerTests: XCTestCase {

slather.given(
.readTestableTargetsNames(
projectDir: .value(config.projectDir),
fileName: ".testable.targets.generated.txt",
filePath: .value(try! config.projectDir.appending(path: ".testable.targets.generated.txt")),
willReturn: actualWarnings.keys.asArray
)
)
Expand Down Expand Up @@ -181,7 +180,8 @@ class WarningLimitsUntrackedCheckerTests: XCTestCase {
trackingNewFoldersCommitMessage: "trackingNewFoldersCommitMessage",
loweringWarningLimitsCommitMessage: "loweringWarningLimitsCommitMessage",
committeeName: "committeeName",
committeeEmail: "committeeEmail"
committeeEmail: "committeeEmail",
testableTargetsListFile: .relative(try! RelativePath(".testable.targets.generated.txt"))
)
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftlaneTests/IssueKeyParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import XCTest

final class IssueKeyParserTests: XCTestCase {
func test_parsingCommentInGitLab() throws {
let parser = IssueKeyParser(jiraProjectKey: "ABCD")
let parser = JiraIssueKeyParser(jiraProjectKey: "ABCD")

try XCTAssertEqual(
parser.parse(from: "ABCD-0000 test"),
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftlaneTests/Services/ChangelogFactoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class ChangelogFactoryTests: XCTestCase {
var logger: LoggingMock!
var gitlabCIEnvironmentReader: GitLabCIEnvironmentReadingMock!
var jiraClient: JiraAPIClientProtocolMock!
var issueKeySearcher: IssueKeySearchingMock!
var issueKeySearcher: JiraIssueKeySearchingMock!

override func setUp() {
super.setUp()

logger = LoggingMock()
gitlabCIEnvironmentReader = GitLabCIEnvironmentReadingMock()
jiraClient = JiraAPIClientProtocolMock()
issueKeySearcher = IssueKeySearchingMock()
issueKeySearcher = JiraIssueKeySearchingMock()

factory = ChangelogFactory(
logger: logger,
Expand Down

0 comments on commit 7180c6b

Please sign in to comment.