Skip to content

Commit

Permalink
[#425] Add KIF
Browse files Browse the repository at this point in the history
  • Loading branch information
blyscuit committed Jan 10, 2023
1 parent 054d083 commit 61e3b5e
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/wiki/Project-Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ There are 3 default targets in a project:

- {ProjectName}
- {ProjectName}Tests
- {ProjectName}KIFUITests
- {ProjectName}UITests

### Schemes
Expand Down
22 changes: 22 additions & 0 deletions .github/wiki/Standard-File-Organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ To keep all current and upcoming iOS projects aligned, we standardize an iOS pro
│   ├── Data+Decode.swift
│   ├── String+Data.swift
│   └── TestError.swift
└── {ProjectName}KIFUITests
   ├── Configurations
   │   └── Plists
   └── Sources
   ├── AccessibilityIdentifiers
   │   ├── Login
   │   └── Home
   ├── Flows
   │   ├── Login
   │   └── Home
   ├── Screens
   │   ├── Login
   │   └── Home
   ├── Specs
   │   ├── Login
   │   └── Home
   └── Utilities
   └── KIF+Swift.swift
└── {ProjectName}UITests
   ├── Configurations
   │   └── Plists
Expand Down Expand Up @@ -146,6 +164,10 @@ This folder contains the main sources of the project. There are three sub-folder

This folder contains the unit testing and integration testing of the main project.

## {ProjectName}KIFUITests

This folder contains the KIF UI testing of the main project. Use KIF instead of UITests for speed and reliability.

## {ProjectName}UITests

This folder contains the UI testing of the main project.
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ included:
- {PROJECT_NAME}
- {PROJECT_NAME}Tests
- {PROJECT_NAME}UITests
- {PROJECT_NAME}KIFUITests

excluded:
- {PROJECT_NAME}Tests/Sources/Mocks/Sourcery/AutoMockable.generated.swift
Expand Down
6 changes: 6 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ target '{PROJECT_NAME}' do
testing_pods
end

target '{PROJECT_NAME}KIFUITests' do
testing_pods
pod 'KIF', :configurations => ['Debug Staging', 'Debug Production']
pod 'KIF/IdentifierTests', :configurations => ['Debug Staging', 'Debug Production']
end

target '{PROJECT_NAME}UITests' do
testing_pods
end
Expand Down
1 change: 1 addition & 0 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension Project {
targets: [
.mainTarget(name: name, bundleId: bundleId),
.testsTarget(name: name, bundleId: bundleId),
.kifUITestsTarget(name: name, bundleId: bundleId),
.uiTestsTarget(name: name, bundleId: bundleId)
],
schemes: [
Expand Down
5 changes: 4 additions & 1 deletion Tuist/ProjectDescriptionHelpers/Scheme+Initializing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ extension Scheme {
name: name,
shared: true,
buildAction: .buildAction(targets: ["\(name)"]),
testAction: .targets(["\(name)Tests", "\(name)UITests"], configuration: debugConfigName),
testAction: .targets(
["\(name)Tests", "\(name)KIFUITests", "\(name)UITests"],
configuration: debugConfigName
),
runAction: .runAction(configuration: debugConfigName),
archiveAction: .archiveAction(configuration: releaseConfigName),
profileAction: .profileAction(configuration: debugConfigName),
Expand Down
17 changes: 17 additions & 0 deletions Tuist/ProjectDescriptionHelpers/Target+Initializing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ extension Target {
)
}

public static func kifUITestsTarget(name: String, bundleId: String) -> Target {
let targetName = "\(name)KIFUITests"
return Target(
name: targetName,
platform: .iOS,
product: .unitTests,
bundleId: bundleId,
infoPlist: "\(targetName)/\(plistsPath)/Info.plist",
sources: ["\(targetName)/**"],
resources: [
"\(targetName)/**/.gitkeep", // To include empty folders
"\(targetName)/Resources/**/*"
],
dependencies: [.target(name: name)]
)
}

public static func uiTestsTarget(name: String, bundleId: String) -> Target {
let targetName = "\(name)UITests"
return Target(
Expand Down
1 change: 1 addition & 0 deletions fastlane/Constants/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ enum Constant {

static let testTarget: String = "\(projectName)Tests"
static let uiTestTarget: String = "\(projectName)UITests"
static let kifUITestTarget: String = "\(projectName)KIFUITests"
}

extension Constant {
Expand Down
6 changes: 5 additions & 1 deletion fastlane/Fastfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ class Fastfile: LaneFile {
desc("Build and Test project")
Test.buildAndTest(
environment: .staging,
targets: [Constant.testTarget, Constant.uiTestTarget],
targets: [
Constant.testTarget,
Constant.kifUITestTarget
Constant.uiTestTarget
],
devices: Constant.devices
)
}
Expand Down
3 changes: 3 additions & 0 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ rename_folder "${CONSTANT_PROJECT_NAME}Tests" "${PROJECT_NAME_NO_SPACES}Tests"
# Rename UI Test folder structure
rename_folder "${CONSTANT_PROJECT_NAME}UITests" "${PROJECT_NAME_NO_SPACES}UITests"

# Rename KIF UI Test folder structure
rename_folder "${CONSTANT_PROJECT_NAME}KIFUITests" "${PROJECT_NAME_NO_SPACES}KIFUITests"

# Rename app folder structure
rename_folder "${CONSTANT_PROJECT_NAME}" "${PROJECT_NAME_NO_SPACES}"

Expand Down
22 changes: 22 additions & 0 deletions {PROJECT_NAME}KIFUITests/Configurations/Plists/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// ApplicationSpec.swift
//

import Foundation
import Nimble
import Quick

final class ApplicationSpec: QuickSpec {

override func spec() {

describe("a {PROJECT_NAME} screen") {

beforeEach {
// Navigate to the testing screen
}

afterEach {
// Navigate to neutral state
}

context("when opens") {

it("shows its UI components") {
self.tester().waitForView(withAccessibilityLabel: "Hello")
}
}
}
}
}
17 changes: 17 additions & 0 deletions {PROJECT_NAME}KIFUITests/Sources/Utilities/KIF+Swift.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// swiftlint:disable:this file_name
//
// KIF+Swift.swift
//

import KIF

extension XCTestCase {

func tester(file: String = #file, _ line: Int = #line) -> KIFUITestActor {
return KIFUITestActor(inFile: file, atLine: line, delegate: self)
}

func system(file: String = #file, _ line: Int = #line) -> KIFSystemTestActor {
return KIFSystemTestActor(inFile: file, atLine: line, delegate: self)
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//
// OptionalUnwrapSpec.swift
//

import Nimble
import Quick

Expand Down Expand Up @@ -26,7 +30,7 @@ final class OptionalUnwrapSpec: QuickSpec {
}

it("returns empty string") {
expect(value.string) == ""
expect(value.string.isEmpty) == true
}
}
}
Expand Down

0 comments on commit 61e3b5e

Please sign in to comment.