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

[#425] As a developer, I would like to have KIF setup when I start a new project #426

Merged
merged 3 commits into from
Mar 31, 2023
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
2 changes: 1 addition & 1 deletion .github/wiki/Project-Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ There are 3 default targets in a project:

- {ProjectName}
- {ProjectName}Tests
- {ProjectName}UITests
- {ProjectName}KIFUITests
vnntsu marked this conversation as resolved.
Show resolved Hide resolved

### Schemes

Expand Down
11 changes: 4 additions & 7 deletions .github/wiki/Standard-File-Organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ To keep all current and upcoming iOS projects aligned, we standardize an iOS pro
│   ├── Data+Decode.swift
│   ├── String+Data.swift
│   └── TestError.swift
└── {ProjectName}UITests
└── {ProjectName}KIFUITests
   ├── Configurations
   │   └── Plists
   ├── Resources
   └── Sources
   ├── AccessibilityIdentifiers
   │   ├── Login
Expand All @@ -121,9 +120,7 @@ To keep all current and upcoming iOS projects aligned, we standardize an iOS pro
   │   ├── Login
   │   └── Home
   └── Utilities
   ├── Data+Decode.swift
   ├── String+Data.swift
   └── TestError.swift
   └── KIF+Swift.swift
```

## README.md
Expand All @@ -146,6 +143,6 @@ 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}UITests
## {ProjectName}KIFUITests

This folder contains the UI testing of the main project.
This folder contains the KIF UI testing of the main project. Use KIF instead of XCUITest for speed and reliability.
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,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
4 changes: 3 additions & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ target '{PROJECT_NAME}' do
testing_pods
end

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

Expand Down
5 changes: 3 additions & 2 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ extension Project {
targets: [
.mainTarget(name: name, bundleId: bundleId),
.testsTarget(name: name, bundleId: bundleId),
.uiTestsTarget(name: name, bundleId: bundleId)
.kifUITestsTarget(name: name, bundleId: bundleId),
],
schemes: [
.productionScheme(name: name),
.stagingScheme(name: name)
.stagingScheme(name: name),
.kifUITestsScheme(name: name)
]
)
}
Expand Down
20 changes: 18 additions & 2 deletions 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"],
configuration: debugConfigName
),
runAction: .runAction(configuration: debugConfigName),
archiveAction: .archiveAction(configuration: releaseConfigName),
profileAction: .profileAction(configuration: debugConfigName),
Expand All @@ -24,11 +27,24 @@ extension Scheme {
name: "\(name) Staging",
shared: true,
buildAction: .buildAction(targets: ["\(name)"]),
testAction: .targets(["\(name)Tests", "\(name)UITests"], configuration: debugConfigName),
testAction: .targets(
["\(name)Tests", "\(name)KIFUITests"],
configuration: debugConfigName
),
runAction: .runAction(configuration: debugConfigName),
archiveAction: .archiveAction(configuration: releaseConfigName),
profileAction: .profileAction(configuration: debugConfigName),
analyzeAction: .analyzeAction(configuration: debugConfigName)
)
}

public static func kifUITestsScheme(name: String) -> Scheme {
let debugConfigName = BuildConfiguration.debugStaging.name
let releaseConfigName = BuildConfiguration.releaseStaging.name
return Scheme(
name: "\(name)KIFUITests",
shared: false,
hidden: true
)
}
}
7 changes: 3 additions & 4 deletions Tuist/ProjectDescriptionHelpers/Target+Initializing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,17 @@ extension Target {
)
}

public static func uiTestsTarget(name: String, bundleId: String) -> Target {
let targetName = "\(name)UITests"
public static func kifUITestsTarget(name: String, bundleId: String) -> Target {
let targetName = "\(name)KIFUITests"
return Target(
name: targetName,
platform: .iOS,
product: .uiTests,
product: .unitTests,
bundleId: bundleId,
infoPlist: "\(targetName)/\(plistsPath)/Info.plist",
sources: ["\(targetName)/**"],
resources: [
"\(targetName)/**/.gitkeep", // To include empty folders
"\(targetName)/Resources/**/*"
],
dependencies: [.target(name: name)]
)
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Constants/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ enum Constant {
// MARK: - Test

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

extension Constant {
Expand Down
5 changes: 4 additions & 1 deletion fastlane/Fastfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ class Fastfile: LaneFile {
desc("Build and Test project")
Test.buildAndTest(
environment: .staging,
targets: [Constant.testTarget, Constant.uiTestTarget],
targets: [
Constant.testTarget,
Constant.kifUITestTarget
],
devices: Constant.devices
)
}
Expand Down
4 changes: 2 additions & 2 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ rename_folder(){
# Rename test folder structure
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
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
Empty file.

This file was deleted.