Skip to content

Commit f708c1a

Browse files
Merge pull request #5 from codewithchris/develop
Nov 2023: Assets and Resources (v1.0.0)
2 parents 1b6a56a + def05d3 commit f708c1a

File tree

80 files changed

+4575
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+4575
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
# cwc_unit-testing-in-ios
1+
# CWC+ Unit Testing in iOS
2+
23
The official CWC source code repository of Unit Testing in iOS course
4+
5+
Project files are grouped by Module and Lesson

module-01/lesson-02/CWCUnitTesting/CWCUnitTesting.xcodeproj/project.pbxproj

Lines changed: 591 additions & 0 deletions
Large diffs are not rendered by default.

module-01/lesson-02/CWCUnitTesting/CWCUnitTesting.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"platform" : "ios",
6+
"size" : "1024x1024"
7+
}
8+
],
9+
"info" : {
10+
"author" : "xcode",
11+
"version" : 1
12+
}
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// CWCUnitTestingApp.swift
3+
// CWCUnitTesting
4+
//
5+
// Created by ヒットり on 11/12/23.
6+
//
7+
8+
import SwiftUI
9+
10+
@main
11+
struct CWCUnitTestingApp: App {
12+
var body: some Scene {
13+
WindowGroup {
14+
ContentView()
15+
}
16+
}
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// ContentView.swift
3+
// CWCUnitTesting
4+
//
5+
// Created by ヒットり on 11/12/23.
6+
//
7+
8+
import SwiftUI
9+
10+
struct ContentView: View {
11+
var body: some View {
12+
VStack {
13+
Image(systemName: "globe")
14+
.imageScale(.large)
15+
.foregroundStyle(.tint)
16+
Text("Hello, world!")
17+
}
18+
.padding()
19+
}
20+
}
21+
22+
#Preview {
23+
ContentView()
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// SimpleMath.swift
3+
// CWCUnitTesting
4+
//
5+
// Created by ヒットり on 11/12/23.
6+
//
7+
8+
import Foundation
9+
10+
class SimpleMath {
11+
12+
func addTen(to number: Int) -> Int {
13+
return number + 10
14+
}
15+
16+
func beSquare(_ number: Int) -> Int {
17+
return number * number
18+
}
19+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// CWCUnitTestingTests.swift
3+
// CWCUnitTestingTests
4+
//
5+
// Created by ヒットり on 11/12/23.
6+
//
7+
8+
import XCTest
9+
@testable import CWCUnitTesting
10+
11+
final class CWCUnitTestingTests: XCTestCase {
12+
13+
var simpleMath: SimpleMath!
14+
15+
override func setUp() {
16+
simpleMath = SimpleMath()
17+
}
18+
19+
override func tearDown() {
20+
simpleMath = nil
21+
}
22+
23+
func testAddTenWorks() {
24+
// Given - Arrange
25+
var expected: Int = 0
26+
27+
// When - Act
28+
expected = simpleMath.addTen(to: 10)
29+
30+
// Then - Assert
31+
XCTAssert(expected == 20, "This should be 20")
32+
XCTAssertTrue(expected == 20)
33+
XCTAssertEqual(expected, 20, "This should be 20")
34+
}
35+
36+
func testBeSquareSucceeds() {
37+
// Given
38+
var expected = 0
39+
40+
// When
41+
expected = simpleMath.beSquare(4)
42+
43+
// Then
44+
XCTAssertEqual(expected, 16)
45+
}
46+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// CWCUnitTestingUITests.swift
3+
// CWCUnitTestingUITests
4+
//
5+
// Created by ヒットり on 11/12/23.
6+
//
7+
8+
import XCTest
9+
10+
final class CWCUnitTestingUITests: XCTestCase {
11+
12+
override func setUpWithError() throws {
13+
// Put setup code here. This method is called before the invocation of each test method in the class.
14+
15+
// In UI tests it is usually best to stop immediately when a failure occurs.
16+
continueAfterFailure = false
17+
18+
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
19+
}
20+
21+
override func tearDownWithError() throws {
22+
// Put teardown code here. This method is called after the invocation of each test method in the class.
23+
}
24+
25+
func testExample() throws {
26+
// UI tests must launch the application that they test.
27+
let app = XCUIApplication()
28+
app.launch()
29+
30+
// Use XCTAssert and related functions to verify your tests produce the correct results.
31+
}
32+
33+
func testLaunchPerformance() throws {
34+
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
35+
// This measures how long it takes to launch your application.
36+
measure(metrics: [XCTApplicationLaunchMetric()]) {
37+
XCUIApplication().launch()
38+
}
39+
}
40+
}
41+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// CWCUnitTestingUITestsLaunchTests.swift
3+
// CWCUnitTestingUITests
4+
//
5+
// Created by ヒットり on 11/12/23.
6+
//
7+
8+
import XCTest
9+
10+
final class CWCUnitTestingUITestsLaunchTests: XCTestCase {
11+
12+
override class var runsForEachTargetApplicationUIConfiguration: Bool {
13+
true
14+
}
15+
16+
override func setUpWithError() throws {
17+
continueAfterFailure = false
18+
}
19+
20+
func testLaunch() throws {
21+
let app = XCUIApplication()
22+
app.launch()
23+
24+
// Insert steps here to perform after app launch but before taking a screenshot,
25+
// such as logging into a test account or navigating somewhere in the app
26+
27+
let attachment = XCTAttachment(screenshot: app.screenshot())
28+
attachment.name = "Launch Screen"
29+
attachment.lifetime = .keepAlways
30+
add(attachment)
31+
}
32+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# YouTube Vapor iOS App
2+
3+
[Video link here](https://youtu.be/2JuqhabkAT8)
4+
5+
# Lesson 5
6+
Deploy the Vapor API to Heroku

0 commit comments

Comments
 (0)