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

[Tests] Fix Existing Tests #21

Merged
merged 1 commit into from
Jan 22, 2018
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
10 changes: 4 additions & 6 deletions ReactiveLists.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

/* Begin PBXBuildFile section */
0ABAC2EBC76C5C0A6354C8F6 /* Pods_ReactiveLists_ReactiveListsExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F35530D29268B112F99A187 /* Pods_ReactiveLists_ReactiveListsExample.framework */; };
2540F4A21F0DA46B003B4C66 /* PlanLib.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2540F4A01F0DA395003B4C66 /* PlanLib.framework */; };
2540F4A91F0DB018003B4C66 /* PlanLib.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2540F4A01F0DA395003B4C66 /* PlanLib.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
2537A64B201672B80044469D /* XCTest+Parameterized.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2537A649201671F20044469D /* XCTest+Parameterized.swift */; };
2541B7321F298A69002C3090 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2541B7311F298A69002C3090 /* Models.swift */; };
2541B73D1F29A13B002C3090 /* Diffing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2541B73C1F29A13B002C3090 /* Diffing.swift */; };
2576640E1F29075C00C037E3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2576640D1F29075C00C037E3 /* AppDelegate.swift */; };
Expand All @@ -36,7 +35,6 @@
258E31E81F0D90BC00D6F324 /* SharedFluxTableViewDataSourceMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 258E31E01F0D90BC00D6F324 /* SharedFluxTableViewDataSourceMocks.swift */; };
258E31E91F0D90BC00D6F324 /* TestFluxCollectionViewModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 258E31E11F0D90BC00D6F324 /* TestFluxCollectionViewModels.swift */; };
258E31EA1F0D90BC00D6F324 /* TestFluxTableViewModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 258E31E21F0D90BC00D6F324 /* TestFluxTableViewModels.swift */; };
258E31EE1F0D9A3600D6F324 /* PGSharedTestUtils.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 258E31ED1F0D9A3600D6F324 /* PGSharedTestUtils.framework */; };
25D0D4321F2952EA00596AED /* FluxTableViewDiffingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25D0D4311F2952EA00596AED /* FluxTableViewDiffingTests.swift */; };
7C24B1408A8B3A147C254BCA /* Pods_ReactiveLists.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 978763204EC113AFD1F7EB54 /* Pods_ReactiveLists.framework */; };
BB2B5FDE1BFA1903A6750AD3 /* Pods_ReactiveListsTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 932473A2DAECE0F923C4B570 /* Pods_ReactiveListsTests.framework */; };
Expand Down Expand Up @@ -66,13 +64,13 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
2540F4A91F0DB018003B4C66 /* PlanLib.framework in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
2537A649201671F20044469D /* XCTest+Parameterized.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCTest+Parameterized.swift"; sourceTree = "<group>"; };
2540F4A01F0DA395003B4C66 /* PlanLib.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PlanLib.framework; path = "../Debug-iphonesimulator/PlanLib.framework"; sourceTree = BUILT_PRODUCTS_DIR; };
2541B7311F298A69002C3090 /* Models.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = "<group>"; };
2541B73C1F29A13B002C3090 /* Diffing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Diffing.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -141,8 +139,6 @@
buildActionMask = 2147483647;
files = (
258E31991F0D8CBC00D6F324 /* ReactiveLists.framework in Frameworks */,
2540F4A21F0DA46B003B4C66 /* PlanLib.framework in Frameworks */,
258E31EE1F0D9A3600D6F324 /* PGSharedTestUtils.framework in Frameworks */,
BB2B5FDE1BFA1903A6750AD3 /* Pods_ReactiveListsTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -222,6 +218,7 @@
258E319C1F0D8CBC00D6F324 /* Tests */ = {
isa = PBXGroup;
children = (
2537A649201671F20044469D /* XCTest+Parameterized.swift */,
258E31DB1F0D90BC00D6F324 /* FluxCollectionViewDataSourceTests.swift */,
258E31DC1F0D90BC00D6F324 /* FluxCollectionViewModelTests.swift */,
258E31DE1F0D90BC00D6F324 /* FluxTableViewDataSourceTests.swift */,
Expand Down Expand Up @@ -585,6 +582,7 @@
258E31E81F0D90BC00D6F324 /* SharedFluxTableViewDataSourceMocks.swift in Sources */,
25D0D4321F2952EA00596AED /* FluxTableViewDiffingTests.swift in Sources */,
258E31E91F0D90BC00D6F324 /* TestFluxCollectionViewModels.swift in Sources */,
2537A64B201672B80044469D /* XCTest+Parameterized.swift in Sources */,
258E31E71F0D90BC00D6F324 /* FluxTableViewModelTests.swift in Sources */,
258E31E61F0D90BC00D6F324 /* FluxTableViewDataSourceTests.swift in Sources */,
258E31EA1F0D90BC00D6F324 /* TestFluxTableViewModels.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
1 change: 0 additions & 1 deletion Tests/FluxCollectionViewDataSourceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import Nimble
import PGSharedTestUtils
@testable import ReactiveLists
import ReactiveSwift
import UIKit
Expand Down
1 change: 0 additions & 1 deletion Tests/FluxCollectionViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2016 PlanGrid. All rights reserved.
//

import PGSharedTestUtils
@testable import ReactiveLists
import ReactiveSwift
import XCTest
Expand Down
1 change: 0 additions & 1 deletion Tests/FluxTableViewDataSourceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import Nimble
import PGSharedTestUtils
@testable import ReactiveLists
import ReactiveSwift
import XCTest
Expand Down
25 changes: 25 additions & 0 deletions Tests/XCTest+Parameterized.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
Allows to perform a parameterized tests, in which each test case can have different inputs and
expecations but in which the test preparation & execution code are shared.
*/
public struct ParameterizedTest<TestParameter> {

public typealias Expectation = (TestParameter) -> Void
public typealias TestCase = (TestParameter, expectation: Expectation)
public typealias TestClosure = (TestParameter, Expectation) -> Void

public static func test(testCases: [TestCase], testClosure: TestClosure) {
testCases.forEach { testClosure($0.0, $0.expectation) }
}
}

/// Run the same expectation code for any number of single parameter cases
///
/// Note: For type inferencing to work on nil cases, you may have to do two things:
///
/// (1) order the nil case first in the list of cases
///
/// (2) explicitly type the nil, e.g. `Optional<String>()`
public func parameterize<A>(cases: A..., expectation: ((A) -> Void)) {
cases.forEach { expectation($0) }
}