@@ -419,7 +419,13 @@ struct ExampleView: View {
419419
420420### Overview
421421
422- Every type containing logic should be tested. Test files should be named ` <TypeToTest>Tests.swift ` .
422+ Every type containing logic should be tested. Test files should be named according to the type of
423+ test:
424+
425+ - ** Unit tests** : ` <TypeToTest>Tests.swift `
426+ - ** Snapshot tests** : ` <TypeToTest>+SnapshotTests.swift `
427+ - ** View Inspector tests** : ` <TypeToTest>+ViewInspectorTests.swift `
428+
423429A test file should exist in the same folder as the type being tested. For example,
424430[ AppProcessorTests] ( https://github.com/bitwarden/ios/blob/main/BitwardenShared/UI/Platform/Application/AppProcessorTests.swift )
425431is in the same folder as
@@ -431,16 +437,42 @@ This makes it convenient to switch between these files or open them side-by-side
431437- ** Unit** : Unit tests compose the majority of tests in the suite. These are written using
432438 [ XCTest] ( https://developer.apple.com/documentation/xctest ) assertions and should be used to test
433439 all logic portions within a type.
434- - ** View ** : In a SwiftUI view test, [ ViewInspector ] ( https://github.com/nalexn/ViewInspector ) is used
435- to test any user interactions within the view. This is commonly used to assert that tapping a
436- button sends an action or effect to the processor, but it can also be used to test other view
437- interactions.
440+ - ** ViewInspector ** : In a SwiftUI view inspector test,
441+ [ ViewInspector ] ( https://github.com/nalexn/ViewInspector ) is used to test any user interactions
442+ within the view. This is commonly used to assert that tapping a button sends an action or effect
443+ to the processor, but it can also be used to test other view interactions.
438444- ** Snapshot** : In addition to using [ ViewInspector] ( https://github.com/nalexn/ViewInspector ) to
439445 interact with a view under test,
440446 [ SnapshotTesting] ( https://github.com/pointfreeco/swift-snapshot-testing ) is used to take snapshots
441447 of the view to test for visual changes from one test run to another. The resulting snapshot images
442448 are stored in the repository and are compared against on future test runs. Any visual differences
443449 on future test runs will result in a failing test. Snapshot tests are usually recorded in light
444- mode, dark mode, and with a large dynamic type size. ⚠️ These tests are done using an ** iPhone 15
445- Pro (17.0.1)** simulator, otherwise tests may fail because of subtle differences between iOS
446- versions.
450+ mode, dark mode, and with a large dynamic type size. ⚠️ These tests are done using a specific
451+ simulator that can be found in the repo
452+ ([ device name] ( https://github.com/bitwarden/ios/blob/main/.test-simulator-device-name ) ,
453+ [ ios version] ( https://github.com/bitwarden/ios/blob/main/.test-simulator-ios-version ) ), otherwise
454+ tests may fail because of subtle differences between iOS versions.
455+
456+ ### Test plans
457+
458+ Test plans are organized in the ` TestPlans ` folder of the iOS repository. Each project has multiple
459+ test plans to allow running specific subsets of tests:
460+
461+ - ` {ProjectName}-Default.xctestplan ` : Includes all tests (unit, snapshot, and view inspector tests)
462+ - ` {ProjectName}-Unit.xctestplan ` : Includes only unit tests (excludes snapshot and view inspector
463+ tests)
464+ - ` {ProjectName}-Snapshot.xctestplan ` : Includes only snapshot tests
465+ - ` {ProjectName}-ViewInspector.xctestplan ` : Includes only view inspector tests
466+
467+ The ` {ProjectName} ` can be one of the following:
468+
469+ - ` Bitwarden ` : The main iOS app
470+ - ` Authenticator ` : The authenticator app
471+ - ` BitwardenKit ` : The shared framework
472+
473+ These test plans enable efficient testing workflows by allowing developers to run only the relevant
474+ subset of tests for their changes.
475+
476+ Additionally, a new environment variable has been added called ` SKIP_SIMULATOR_CHECK_FOR_TESTS `
477+ which is enabled in all Unit test plans so any simulator can be chosen to run such tests instead of
478+ the specific one for the Snapshots to pass.
0 commit comments