Skip to content

Commit

Permalink
Activate PreviewTests
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasBuquet committed Feb 12, 2025
1 parent baf9f39 commit 7f76e4a
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 10 deletions.
4 changes: 2 additions & 2 deletions PreviewTests/Sources/GeneratedPreviewTests.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Generated using Sourcery 2.2.6 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

// swiftlint:disable all
// swiftformat:disable all

import XCTest
@testable import ElementX
@testable import TchapX_Production // Tchap: adjustement

extension PreviewTests {

Expand Down
4 changes: 2 additions & 2 deletions PreviewTests/Sources/PreviewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import Combine
import SwiftUI
import XCTest

@testable import ElementX
@testable import SnapshotTesting
@testable import TchapX_Production // Tchap: adjustement

@MainActor
class PreviewTests: XCTestCase {
private let deviceConfig: ViewImageConfig = .iPhoneX
private let simulatorDevice: String? = "iPhone14,6" // iPhone SE 3rd Generation
private let simulatorDevice: String? = "iPhone17,3" // iPhone 16 // Tchap: adjustement
private let requiredOSVersion = (major: 18, minor: 1)
private let snapshotDevices = ["iPhone 16", "iPad"]
private var recordMode: SnapshotTestingConfiguration.Record = .missing
Expand Down
5 changes: 4 additions & 1 deletion README_TCHAPX_UITests.md → README_TCHAPX_Tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ Les captures générées sont stockées dans le dossier `UITests/Sources/__Snaps
Certains paramètres du simulateur comme la langue ou la géolocalisation peuvent être réglés dans le fichier `TchapX/UITests/SupportingFiles/UITests.xctestplan`. (ne semble pas fonctionner)

Documentation :
- https://developer.apple.com/documentation/xctest
- https://developer.apple.com/documentation/xctest


Les tests Preview sont accessibles de la même manière.
22 changes: 22 additions & 0 deletions TchapX/PreviewTests/SupportingFiles/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>
54 changes: 54 additions & 0 deletions TchapX/PreviewTests/SupportingFiles/PreviewTests.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"configurations" : [
{
"id" : "D789E5F1-30B8-4A23-B20E-281ACE05CFD6",
"name" : "Français",
"options" : {
"language" : "fr",
"locationScenario" : {
"identifier" : "Paris, France",
"referenceType" : "built-in"
},
"region" : "FR"
}
},
{
"id" : "059C4F1C-EAB6-4D96-BA8F-30DF92A365E9",
"name" : "Pseudolanguage",
"options" : {
"language" : "en",
"locationScenario" : {
"identifier" : "London, England",
"referenceType" : "built-in"
},
"region" : "GB"
}
}
],
"defaultOptions" : {
"defaultTestExecutionTimeAllowance" : 60,
"environmentVariableEntries" : [
{
"key" : "IS_RUNNING_UNIT_TESTS",
"value" : "1"
},
{
"enabled" : false,
"key" : "RECORD_FAILURES",
"value" : "true"
}
],
"testExecutionOrdering" : "random",
"testTimeoutsEnabled" : true
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:TchapX.xcodeproj",
"identifier" : "CB69E71180645F7FC67A7031",
"name" : "TchapX-PreviewTests"
}
}
],
"version" : 1
}
57 changes: 57 additions & 0 deletions TchapX/SupportingFiles/target-PreviewTests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: TchapX-PreviewTests

schemes:
TchapX-PreviewTests:
analyze:
config: Debug
archive:
config: Release
build:
targets:
TchapX-PreviewTests: all
profile:
config: Release
run:
config: Debug
disableMainThreadChecker: false
test:
config: Debug
disableMainThreadChecker: false
gatherCoverageData: true
coverageTargets:
- TchapX-Production
testPlans:
- path: ../PreviewTests/SupportingFiles/PreviewTests.xctestplan
# Don't set it as defaultPlan to avoid conflict with ElementX defaultPlan.
defaultPlan: false

targets:
TchapX-PreviewTests:
type: bundle.unit-test
platform: iOS

dependencies:
- target: TchapX-Production
- package: MatrixRustSDK
- package: SnapshotTesting

info:
path: ../PreviewTests/SupportingFiles/Info.plist

settings:
base:
BASE_BUNDLE_IDENTIFIER: fr.gouv.tchapx
BASE_APP_GROUP_IDENTIFIER: fr.gouv.tchapx
APP_GROUP_IDENTIFIER: group.$(BASE_APP_GROUP_IDENTIFIER)
APP_DISPLAY_NAME: TchapX # The name used in the application.
PRODUCT_NAME: PreviewTests
PRODUCT_BUNDLE_IDENTIFIER: ${BASE_BUNDLE_IDENTIFIER}.preview.tests
debug:
release:

sources:
- path: ../../PreviewTests/Sources
excludes:
- "**/__Snapshots__/**"
- path: ../SupportingFiles
- path: ../../ElementX/Sources/Other/Extensions/XCTestCase.swift
2 changes: 2 additions & 0 deletions TchapX/SupportingFiles/target-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ schemes:
defaultPlan: true
- path: ../UITests/SupportingFiles/UITests.xctestplan
defaultPlan: false
- path: ../PreviewTests/SupportingFiles/PreviewTests.xctestplan
defaultPlan: false

targets:
TchapX-Production:
Expand Down
8 changes: 4 additions & 4 deletions TchapX/UITests/SupportingFiles/UITests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"configurations" : [
{
"id" : "183696C6-4CBB-4BCE-8F4C-D2B848395699",
"name" : "English",
"name" : "Français",
"options" : {
"language" : "en",
"region" : "GB"
"language" : "fr",
"region" : "FR"
}
}
],
Expand Down Expand Up @@ -35,7 +35,7 @@
}
],
"locationScenario" : {
"identifier" : "London, England",
"identifier" : "Paris, France",
"referenceType" : "built-in"
},
"targetForVariableExpansion" : {
Expand Down
3 changes: 2 additions & 1 deletion project-tchap-x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ include:
- path: TchapX-NSE/development/SupportingFiles/target.yml
- path: TchapX-ShareExtension/development/SupportingFiles/target.yml

- path: TchapX/SupportingFiles/target-unitTests.yml
- path: TchapX/SupportingFiles/target-UnitTests.yml
- path: TchapX/SupportingFiles/target-UITests.yml
- path: TchapX/SupportingFiles/target-PreviewTests.yml

0 comments on commit 7f76e4a

Please sign in to comment.