Permalink
Browse files

Specify count should increase

The first problem we have is that the table view is never showing any rows. To get it to show a row, we need the count to increase when a message is added. We write a unit test for MessageStore to confirm this behavior. We add a custom error message to make our test failure easier to understand.

Inner Red: Expected store.count to be 1 but was 0
  • Loading branch information...
CodingItWrong committed Jan 2, 2018
1 parent 709ebc3 commit 5ed6c50fe11fa81c9d33e308804618f514798a27
@@ -14,6 +14,7 @@
031D41B11FFB0F3000738CDE /* CreatingAMessageTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031D41B01FFB0F3000738CDE /* CreatingAMessageTest.swift */; };
031D41B51FFB0FDC00738CDE /* MessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031D41B41FFB0FDC00738CDE /* MessagesViewController.swift */; };
031D41B71FFB11F900738CDE /* MessageStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031D41B61FFB11F900738CDE /* MessageStore.swift */; };
031D41BA1FFB131D00738CDE /* MessageStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031D41B91FFB131D00738CDE /* MessageStoreTests.swift */; };
4B32BCF2F40577F8ED96D981 /* EarlGrey.framework in EarlGrey Copy Files */ = {isa = PBXBuildFile; fileRef = ABE0AD732ED68DBB126181AB /* EarlGrey.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
579FB8715C3FAB22FE945D98 /* EarlGrey.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ABE0AD732ED68DBB126181AB /* EarlGrey.framework */; };
7558B69A86CACB1E4542B5A1 /* Pods_LearnTDDInCocoaTouch.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B72CFF61DC9E26B62D5D706C /* Pods_LearnTDDInCocoaTouch.framework */; };
@@ -58,6 +59,7 @@
031D41B01FFB0F3000738CDE /* CreatingAMessageTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreatingAMessageTest.swift; sourceTree = "<group>"; };
031D41B41FFB0FDC00738CDE /* MessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesViewController.swift; sourceTree = "<group>"; };
031D41B61FFB11F900738CDE /* MessageStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageStore.swift; sourceTree = "<group>"; };
031D41B91FFB131D00738CDE /* MessageStoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageStoreTests.swift; sourceTree = "<group>"; };
1F125ED073084CD5A75837DD /* Pods-LearnTDDInCocoaTouch.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LearnTDDInCocoaTouch.release.xcconfig"; path = "Pods/Target Support Files/Pods-LearnTDDInCocoaTouch/Pods-LearnTDDInCocoaTouch.release.xcconfig"; sourceTree = "<group>"; };
5BA5D5DB522BFD732C81EB16 /* EarlGrey.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = EarlGrey.swift; sourceTree = "<group>"; };
85A9AE3C4EEE4CA0BB3F364C /* Pods_LearnTDDInCocoaTouchTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LearnTDDInCocoaTouchTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -125,6 +127,7 @@
031D41A31FFB0D8B00738CDE /* LearnTDDInCocoaTouchTests */ = {
isa = PBXGroup;
children = (
031D41B81FFB130D00738CDE /* Unit */,
031D41AF1FFB0F0500738CDE /* E2E */,
031D41A61FFB0D8B00738CDE /* Info.plist */,
5BA5D5DB522BFD732C81EB16 /* EarlGrey.swift */,
@@ -140,6 +143,14 @@
path = E2E;
sourceTree = "<group>";
};
031D41B81FFB130D00738CDE /* Unit */ = {
isa = PBXGroup;
children = (
031D41B91FFB131D00738CDE /* MessageStoreTests.swift */,
);
path = Unit;
sourceTree = "<group>";
};
343B00DB7565ACD492A7E328 /* Pods */ = {
isa = PBXGroup;
children = (
@@ -384,6 +395,7 @@
buildActionMask = 2147483647;
files = (
031D41B11FFB0F3000738CDE /* CreatingAMessageTest.swift in Sources */,
031D41BA1FFB131D00738CDE /* MessageStoreTests.swift in Sources */,
C5200FA6F6ECD823D802E789 /* EarlGrey.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -0,0 +1,21 @@
import XCTest
@testable import LearnTDDInCocoaTouch
class MessageStoreTests: XCTestCase {
var store: MessageStore!
override func setUp() {
super.setUp()
store = MessageStore()
}
func testCountShouldIncreaseWhenMessageCreated() {
store.create("Some message")
let count = store.count
XCTAssertEqual(count, 1, "Expected store.count to be 1 but was \(count)")
}
}

0 comments on commit 5ed6c50

Please sign in to comment.