Skip to content
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

Rename sut to subject #45

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Tests/XCDiffCommandTests/CommandBasedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ final class CommandBasedTests: XCTestCase {
commands.forEach { command in
print("Checking '\(command)'.")
let printer = PrinterMock()
let sut = CommandRunner(printer: printer)
let exitCode = sut.run(with: command.command)
let subject = CommandRunner(printer: printer)
let exitCode = subject.run(with: command.command)

XCTAssertEqual(printer.output, command.expectedOutput,
"'\(command)' didn't produce expected output.")
Expand Down
4 changes: 2 additions & 2 deletions Tests/XCDiffCoreTests/Comparator/ComparatorTypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ final class ComperatorTypeTests: XCTestCase {
func testTag_whenCustom() {
// Given
let comparator = ComparatorMock(tag: "Tag1")
let sut = ComparatorType.custom(comparator)
let subject = ComparatorType.custom(comparator)

// When / Then
XCTAssertEqual(sut.tag, "Tag1")
XCTAssertEqual(subject.tag, "Tag1")
}
}
22 changes: 11 additions & 11 deletions Tests/XCDiffCoreTests/Comparator/TargetsComparatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ import Foundation
import XCTest

final class TargetsComparatorTests: XCTestCase {
private var sut: TargetsComparator!
private var subject: TargetsComparator!

override func setUp() {
super.setUp()

sut = TargetsComparator()
subject = TargetsComparator()
}

func testTag() {
// When / Then
XCTAssertEqual(sut.tag, "targets")
XCTAssertEqual(subject.tag, "targets")
}

func testCompare_whenHaveNoTargets() throws {
Expand All @@ -40,7 +40,7 @@ final class TargetsComparatorTests: XCTestCase {
.projectDescriptor()

// When
let actual = try sut.compare(first, second, parameters: .all)
let actual = try subject.compare(first, second, parameters: .all)

// Then
XCTAssertEqual(actual, [
Expand All @@ -59,7 +59,7 @@ final class TargetsComparatorTests: XCTestCase {
.projectDescriptor()

// When
let actual = try sut.compare(first, second, parameters: .all)
let actual = try subject.compare(first, second, parameters: .all)

// Then
XCTAssertEqual(actual, [
Expand All @@ -79,7 +79,7 @@ final class TargetsComparatorTests: XCTestCase {
.projectDescriptor()

// When
let actual = try sut.compare(first, second, parameters: .all)
let actual = try subject.compare(first, second, parameters: .all)

// Then
let expected = [
Expand All @@ -106,8 +106,8 @@ final class TargetsComparatorTests: XCTestCase {
.projectDescriptor()

// When
let actual = try sut.compare(first, second,
parameters: .init(targets: .some(["A", "B", "C", "D"]), configurations: .none))
let actual = try subject.compare(first, second,
parameters: .init(targets: .some(["A", "B", "C", "D"]), configurations: .none))

// Then
let expected = [
Expand Down Expand Up @@ -137,7 +137,7 @@ final class TargetsComparatorTests: XCTestCase {
configurations: .all)

// When / Then
XCTAssertThrowsError(try sut.compare(first, second, parameters: parameters)) { error in
XCTAssertThrowsError(try subject.compare(first, second, parameters: parameters)) { error in
XCTAssertEqual(error.localizedDescription, "Cannot find target \"NOT_EXISTING\" in both projects")
}
}
Expand All @@ -156,8 +156,8 @@ final class TargetsComparatorTests: XCTestCase {
.projectDescriptor()

// When
let actual = try sut.compare(first, second,
parameters: .all)
let actual = try subject.compare(first, second,
parameters: .all)

// Then
let expected = [
Expand Down
60 changes: 30 additions & 30 deletions Tests/XCDiffCoreTests/DefaultProjectComparatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ final class DefaultProjectComparatorTests: XCTestCase {

func testCompare_whenNoComparators_success() throws {
// Given
let sut = DefaultProjectComparator(comparators: [],
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: false)
let subject = DefaultProjectComparator(comparators: [],
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: false)

// When
let result = try sut.compare(firstPath, secondPath, parameters: parametersAll)
let result = try subject.compare(firstPath, secondPath, parameters: parametersAll)

// Then
XCTAssertTrue(result.success)
Expand All @@ -43,13 +43,13 @@ final class DefaultProjectComparatorTests: XCTestCase {
// Given
let comparator = ComparatorMock(tag: "Comparator1") { _, _, _ in [] }
let comparators: [XCDiffCore.Comparator] = [comparator]
let sut = DefaultProjectComparator(comparators: comparators,
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: false)
let subject = DefaultProjectComparator(comparators: comparators,
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: false)

// When
let result = try sut.compare(firstPath, secondPath, parameters: parametersAll)
let result = try subject.compare(firstPath, secondPath, parameters: parametersAll)

// Then
XCTAssertTrue(result.success)
Expand All @@ -61,13 +61,13 @@ final class DefaultProjectComparatorTests: XCTestCase {
let tag = "Comparator1"
let comparator = ComparatorMock(tag: tag) { _, _, _ in [CompareResult(tag: tag)] }
let comparators: [XCDiffCore.Comparator] = [comparator]
let sut = DefaultProjectComparator(comparators: comparators,
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: false)
let subject = DefaultProjectComparator(comparators: comparators,
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: false)

// When
let result = try sut.compare(firstPath, secondPath, parameters: parametersAll)
let result = try subject.compare(firstPath, secondPath, parameters: parametersAll)

// Then
XCTAssertTrue(result.success)
Expand All @@ -79,13 +79,13 @@ final class DefaultProjectComparatorTests: XCTestCase {
let tag = "Comparator1"
let comparator = ComparatorMock(tag: tag) { _, _, _ in [CompareResult(tag: tag)] }
let comparators: [XCDiffCore.Comparator] = [comparator]
let sut = DefaultProjectComparator(comparators: comparators,
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: true)
let subject = DefaultProjectComparator(comparators: comparators,
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: true)

// When
let result = try sut.compare(firstPath, secondPath, parameters: parametersAll)
let result = try subject.compare(firstPath, secondPath, parameters: parametersAll)

// Then
XCTAssertTrue(result.success)
Expand All @@ -97,13 +97,13 @@ final class DefaultProjectComparatorTests: XCTestCase {
let tag = "Comparator1"
let comparator = ComparatorMock(tag: tag) { _, _, _ in [CompareResult(tag: tag, onlyInFirst: ["file.txt"])] }
let comparators: [XCDiffCore.Comparator] = [comparator]
let sut = DefaultProjectComparator(comparators: comparators,
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: false)
let subject = DefaultProjectComparator(comparators: comparators,
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: false)

// When
let result = try sut.compare(firstPath, secondPath, parameters: parametersAll)
let result = try subject.compare(firstPath, secondPath, parameters: parametersAll)

// Then
XCTAssertFalse(result.success)
Expand All @@ -122,13 +122,13 @@ final class DefaultProjectComparatorTests: XCTestCase {
let tag = "Comparator1"
let comparator = ComparatorMock(tag: tag) { _, _, _ in [CompareResult(tag: tag, onlyInFirst: ["file.txt"])] }
let comparators: [XCDiffCore.Comparator] = [comparator]
let sut = DefaultProjectComparator(comparators: comparators,
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: true)
let subject = DefaultProjectComparator(comparators: comparators,
resultRenderer: UniversalResultRenderer(format: .console, verbose: true),
xcodeProjLoader: XcodeProjLoaderMock(),
differencesOnly: true)

// When
let result = try sut.compare(firstPath, secondPath, parameters: parametersAll)
let result = try subject.compare(firstPath, secondPath, parameters: parametersAll)

// Then
XCTAssertFalse(result.success)
Expand Down
54 changes: 27 additions & 27 deletions Tests/XCDiffCoreTests/Library/ComparatorParametersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,74 +21,74 @@ import XCTest
final class ComparatorParametersTests: XCTestCase {
func testInit() {
// When
let sut = ComparatorParameters(targets: .all, configurations: .none)
let subject = ComparatorParameters(targets: .all, configurations: .none)

// Then
XCTAssertEqual(sut.targets, .all)
XCTAssertEqual(sut.configurations, .none)
XCTAssertEqual(subject.targets, .all)
XCTAssertEqual(subject.configurations, .none)
}

func testOptionFilter_whenNone() {
// Given
let sut: ComparatorParameters.Option<String> = .none
let subject: ComparatorParameters.Option<String> = .none
let data = ["A", "B", "C"]

// When / Then
XCTAssertEqual(data.filter(by: sut), [])
XCTAssertEqual(data.filter(by: subject), [])
}

func testOptionFilter_whenOnly() {
// Given
let sut: ComparatorParameters.Option<String> = .only("B")
let subject: ComparatorParameters.Option<String> = .only("B")
let data = ["A", "B", "C"]

// When / Then
XCTAssertEqual(data.filter(by: sut), ["B"])
XCTAssertEqual(data.filter(by: subject), ["B"])
}

func testOptionFilter_whenSome() {
// Given
let sut: ComparatorParameters.Option<String> = .some(["B", "C"])
let subject: ComparatorParameters.Option<String> = .some(["B", "C"])
let data = ["A", "B", "C"]

// When / Then
XCTAssertEqual(data.filter(by: sut), ["B", "C"])
XCTAssertEqual(data.filter(by: subject), ["B", "C"])
}

func testOptionFilter_whenAll() {
// Given
let sut: ComparatorParameters.Option<String> = .all
let subject: ComparatorParameters.Option<String> = .all
let data = ["A", "B", "C"]

// When / Then
XCTAssertEqual(data.filter(by: sut), ["A", "B", "C"])
XCTAssertEqual(data.filter(by: subject), ["A", "B", "C"])
}

func testValues() {
// Given
let sut1: ComparatorParameters.Option<String> = .all
let sut2: ComparatorParameters.Option<String> = .only("A")
let sut3: ComparatorParameters.Option<String> = .some(["A", "B"])
let sut4: ComparatorParameters.Option<String> = .none
let subject1: ComparatorParameters.Option<String> = .all
let subject2: ComparatorParameters.Option<String> = .only("A")
let subject3: ComparatorParameters.Option<String> = .some(["A", "B"])
let subject4: ComparatorParameters.Option<String> = .none

// When / Then
XCTAssertNil(sut1.values())
XCTAssertEqual(sut2.values(), ["A"])
XCTAssertEqual(sut3.values(), ["A", "B"])
XCTAssertEqual(sut4.values(), [])
XCTAssertNil(subject1.values())
XCTAssertEqual(subject2.values(), ["A"])
XCTAssertEqual(subject3.values(), ["A", "B"])
XCTAssertEqual(subject4.values(), [])
}

func testContains() {
// Given
let sut1: ComparatorParameters.Option<String> = .all
let sut2: ComparatorParameters.Option<String> = .only("A")
let sut3: ComparatorParameters.Option<String> = .some(["A", "B"])
let sut4: ComparatorParameters.Option<String> = .none
let subject1: ComparatorParameters.Option<String> = .all
let subject2: ComparatorParameters.Option<String> = .only("A")
let subject3: ComparatorParameters.Option<String> = .some(["A", "B"])
let subject4: ComparatorParameters.Option<String> = .none

// When / Then
XCTAssertTrue(sut1.contains("A"))
XCTAssertTrue(sut2.contains("A"))
XCTAssertTrue(sut3.contains("A"))
XCTAssertFalse(sut4.contains("A"))
XCTAssertTrue(subject1.contains("A"))
XCTAssertTrue(subject2.contains("A"))
XCTAssertTrue(subject3.contains("A"))
XCTAssertFalse(subject4.contains("A"))
}
}
20 changes: 10 additions & 10 deletions Tests/XCDiffCoreTests/Library/CompareResultTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,43 @@ import XCTest
final class CompareResultTests: XCTestCase {
func testSame_whenEmptyArrays_true() {
// Given
let sut = compareResult(onlyInFirst: [], onlyInSecond: [], differentValues: [])
let subject = compareResult(onlyInFirst: [], onlyInSecond: [], differentValues: [])

// When / Then
XCTAssertTrue(sut.same())
XCTAssertTrue(subject.same())
}

func testSame_whenEmpty_true() {
// Given
let sut = compareResult(onlyInFirst: [], onlyInSecond: [], differentValues: [])
let subject = compareResult(onlyInFirst: [], onlyInSecond: [], differentValues: [])

// When / Then
XCTAssertTrue(sut.same())
XCTAssertTrue(subject.same())
}

func testSame_whenOnlyInFirst_false() {
// Given
let sut = compareResult(onlyInFirst: ["A"], onlyInSecond: [], differentValues: [])
let subject = compareResult(onlyInFirst: ["A"], onlyInSecond: [], differentValues: [])

// When / Then
XCTAssertFalse(sut.same())
XCTAssertFalse(subject.same())
}

func testSame_whenOnlyInSecond_false() {
// Given
let sut = compareResult(onlyInFirst: [], onlyInSecond: ["A"], differentValues: [])
let subject = compareResult(onlyInFirst: [], onlyInSecond: ["A"], differentValues: [])

// When / Then
XCTAssertFalse(sut.same())
XCTAssertFalse(subject.same())
}

func testSame_whenOnlyDifferentValues_false() {
// Given
let differentValues = self.differentValues(context: "context", first: "A", second: "B")
let sut = compareResult(onlyInFirst: [], onlyInSecond: [], differentValues: [differentValues])
let subject = compareResult(onlyInFirst: [], onlyInSecond: [], differentValues: [differentValues])

// When / Then
XCTAssertFalse(sut.same())
XCTAssertFalse(subject.same())
}

func testEqual_whenSameObject_true() {
Expand Down
Loading