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

Beta support for Swift Testing, and other improvements. #867

Merged
merged 50 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2d45183
wip
mbrandonw Jul 3, 2024
3cda2a7
wip
mbrandonw Jul 3, 2024
e71cde1
wip
mbrandonw Jul 3, 2024
822361a
wip
mbrandonw Jul 3, 2024
4201a54
wip
mbrandonw Jul 3, 2024
2408cc7
tests
mbrandonw Jul 3, 2024
8f8da79
wip
mbrandonw Jul 3, 2024
3e37ab0
migration guide
mbrandonw Jul 4, 2024
1efdcec
wip
mbrandonw Jul 4, 2024
b479fa4
wip
mbrandonw Jul 4, 2024
7760adf
wip
stephencelis Jul 4, 2024
7ad8430
Update Sources/SnapshotTesting/AssertSnapshot.swift
stephencelis Jul 4, 2024
cf5666e
wip
mbrandonw Jul 4, 2024
9a6f879
formatting
mbrandonw Jul 4, 2024
104d43f
wip
stephencelis Jul 4, 2024
d69e681
format
stephencelis Jul 4, 2024
9125d57
more
stephencelis Jul 4, 2024
0b9826b
wip
stephencelis Jul 4, 2024
ca6f4dc
fix
stephencelis Jul 4, 2024
d8fecd2
Merge remote-tracking branch 'origin/main' into swift-testing
stephencelis Jul 4, 2024
d84b345
Merge remote-tracking branch 'origin/main' into swift-testing
stephencelis Jul 4, 2024
ac36312
Make record mode opaque.
mbrandonw Jul 4, 2024
246c2e1
more docs
mbrandonw Jul 4, 2024
9d2c475
wip
mbrandonw Jul 4, 2024
9810df4
wip
mbrandonw Jul 4, 2024
0c6b449
Added new 'failed' record strategy, and wrote some tests.
mbrandonw Jul 4, 2024
a30e1ad
remove test artificats
mbrandonw Jul 4, 2024
54945d9
wip
mbrandonw Jul 4, 2024
f18aa61
more docs
mbrandonw Jul 4, 2024
f78bb29
fix linux tests
mbrandonw Jul 4, 2024
4463f37
more test fixes
mbrandonw Jul 4, 2024
6b5147e
test clean up
mbrandonw Jul 4, 2024
a3dd71d
debugging
mbrandonw Jul 4, 2024
6031605
debug
mbrandonw Jul 4, 2024
7617c60
wip
mbrandonw Jul 4, 2024
b87309a
fix
mbrandonw Jul 4, 2024
2de533c
fix tests
mbrandonw Jul 4, 2024
ef4f24e
wip
stephencelis Jul 4, 2024
aaf6ce4
wip
stephencelis Jul 4, 2024
f98a7e7
wip
stephencelis Jul 4, 2024
30c3469
make snapshot configuration optional
mbrandonw Jul 8, 2024
50e71d5
make snapshot configuration optional
mbrandonw Jul 8, 2024
42feef6
clean up
mbrandonw Jul 8, 2024
bd68b8f
fix
mbrandonw Jul 8, 2024
3eba8e2
indent
mbrandonw Jul 8, 2024
9a5361e
typo
mbrandonw Jul 8, 2024
c4842c3
more clean up
mbrandonw Jul 8, 2024
2dc8dab
record before difftool
mbrandonw Jul 8, 2024
ea63fe0
more tests
mbrandonw Jul 8, 2024
f4227b3
clean up test code
mbrandonw Jul 8, 2024
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
Prev Previous commit
Next Next commit
wip
  • Loading branch information
stephencelis committed Jul 4, 2024
commit 104d43f0f54b5b226cd8bfa118a5290c96cecea4
6 changes: 0 additions & 6 deletions Sources/SnapshotTesting/AssertSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import XCTest

/// Enhances failure messages with a command line diff tool expression that can be copied and pasted
/// into a terminal.
///
/// This API has been deprecated in favor of
/// ``withSnapshotTesting(diffTool:record:operation:)-7xmhk``.
@available(*, deprecated, message: "Use 'withSnapshotTesting' to customize the diff tool. See the documentation for more information.")
public var diffTool: SnapshotTestingConfiguration.DiffTool {
get { _diffTool }
Expand All @@ -15,9 +12,6 @@ public var diffTool: SnapshotTestingConfiguration.DiffTool {
public var _diffTool: SnapshotTestingConfiguration.DiffTool = .default

/// Whether or not to record all new references.
///
/// This API has been deprecated in favor of
/// ``withSnapshotTesting(diffTool:record:operation:)-7xmhk``.
@available(*, deprecated, message: "Use 'withSnapshotTesting' to customize the record mode. See the documentation for more information.")
public var isRecording: Bool {
get { SnapshotTestingConfiguration.current?.record ?? _record == .all }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ``SnapshotTesting/diffTool``

@DeprecationSummary {
Use ``withSnapshotTesting(record:diffTool:operation:)-59u9g`` to customize the diff tool, instead.
See <doc:MigratingTo1.17> for more information.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ``SnapshotTesting/isRecording``

@DeprecationSummary {
Use ``withSnapshotTesting(record:diffTool:operation:)-59u9g`` to customize the record mode,
instead. See <doc:MigratingTo1.17> for more information.
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ diffs of files, but only works when the command line tool accepts a very narrow
_e.g._ `ksdiff /path/to/file1.png /path/to/file2.png`.

We have greatly improved upon all of these problems by introducing the new
``withSnapshotTesting(diffTool:record:operation:)-7xmhk`` tool for customizing snapshots. It
``withSnapshotTesting(record:diffTool:operation:)-59u9g`` tool for customizing snapshots. It
allows you to customize how the `assertSnapshot` tool behaves for a well-defined scope.

Rather than overriding `isRecording` or `diffTool` directly in your tests, you can wrap your test in
Expand Down
4 changes: 2 additions & 2 deletions Sources/SnapshotTesting/Documentation.docc/SnapshotTesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Powerfully flexible snapshot testing.

### Configuration

- ``withSnapshotTesting(diffTool:record:operation:)-7xmhk``
- ``withSnapshotTesting(record:diffTool:operation:)-59u9g``
- ``SnapshotTestingConfiguration``

### Deprecations

- <doc:Deprecations>
- <doc:SnapshotTestingDeprecations>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ``SnapshotTesting/withSnapshotTesting(diffTool:record:operation:)-7xmhk``
# ``SnapshotTesting/withSnapshotTesting(record:diffTool:operation:)-59u9g``

## Topics

### Overloads

- ``withSnapshotTesting(diffTool:record:operation:)-4s6ad``
- ``withSnapshotTesting(record:diffTool:operation:)-b1i4``
8 changes: 4 additions & 4 deletions Sources/SnapshotTesting/SnapshotTestingConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
/// ```
///
/// - Parameters:
/// - diffTool: The diff tool to use while asserting snapshots.
/// - record: The record mode to use while asserting snapshots.
/// - diffTool: The diff tool to use while asserting snapshots.
/// - operation: The operation to perform.
public func withSnapshotTesting<R>(
diffTool: SnapshotTestingConfiguration.DiffTool? = nil,
record: SnapshotTestingConfiguration.Record? = nil,
diffTool: SnapshotTestingConfiguration.DiffTool? = nil,
operation: () throws -> R
) rethrows -> R {
try SnapshotTestingConfiguration.$current.withValue(
Expand All @@ -40,10 +40,10 @@ public func withSnapshotTesting<R>(

/// Customizes `assertSnapshot` for the duration of an asynchronous operation.
///
/// See ``withSnapshotTesting(diffTool:record:operation:)-7xmhk`` for more information.
/// See ``withSnapshotTesting(record:diffTool:operation:)-59u9g`` for more information.
public func withSnapshotTesting<R>(
diffTool: SnapshotTestingConfiguration.DiffTool? = nil,
record: SnapshotTestingConfiguration.Record? = nil,
diffTool: SnapshotTestingConfiguration.DiffTool? = nil,
operation: () async throws -> R
) async rethrows -> R {
try await SnapshotTestingConfiguration.$current.withValue(
Expand Down
4 changes: 2 additions & 2 deletions Sources/SnapshotTesting/SnapshotsTestTrait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
testCase: Test.Case?
) async throws {
try await withSnapshotTesting(
diffTool: configuration.diffTool,
record: configuration.record
record: configuration.record,
diffTool: configuration.diffTool
) {
try await function()
}
Expand Down
Loading