Skip to content

Add ArbitraryError and support for default stub values - #29

Merged
prachigauriar merged 1 commit into
mainfrom
default-stub-values
Nov 14, 2026
Merged

prachigauriar merged 1 commit into
mainfrom
default-stub-values

Conversation

@prachigauriar

@prachigauriar prachigauriar commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator
  • Add the DefaultStubValueProviding protocol, which lets a type
    provide a default value for stubs that return it. Conform common
    standard library and Foundation types, using recognizable
    placeholder values where possible.
  • Add Stub.init(), which returns the default stub value until the
    stub is configured, for return types that conform to
    DefaultStubValueProviding.
  • Add ThrowingStub.init() for stubs whose error type is any Error.
    It throws an unspecified error until the stub is configured.
  • Add ArbitraryError, an error type for tests that just need an
    error to throw, and a randomError function on
    RandomValueGenerating that creates one with a random description
    beginning with the calling file and function.
  • Rewrite the guidance on stub properties in Using Stubs to
    recommend default-initialized stubs, and document ArbitraryError.
  • Rename the randomError example in Using Random Value Generation
    so it doesn’t collide with the new function.
  • Mention the new types in the README and add a 1.7.0 changelog
    entry.

  - Add the DefaultStubValueProviding protocol, which lets a type
    provide a default value for stubs that return it. Conform common
    standard library and Foundation types, using recognizable
    placeholder values where possible.
  - Add Stub.init(), which returns the default stub value until the
    stub is configured, for return types that conform to
    DefaultStubValueProviding.
  - Add ThrowingStub.init() for stubs whose error type is any Error.
    It throws an unspecified error until the stub is configured.
  - Add ArbitraryError, an error type for tests that just need an
    error to throw, and a randomError function on
    RandomValueGenerating that creates one with a random description
    beginning with the calling file and function.
  - Rewrite the guidance on stub properties in Using Stubs to
    recommend default-initialized stubs, and document ArbitraryError.
  - Rename the randomError example in Using Random Value Generation
    so it doesn’t collide with the new function.
  - Mention the new types in the README and add a 1.7.0 changelog
    entry.
@github-actions

Copy link
Copy Markdown

Code Coverage Report

Overall Coverage: 99.78% (919 of 921)

DevRandom: 100.00% (242 of 242)
File Coverage Covered Lines Executable Lines
BinaryFloatingPoint+Random.swift 100.00% 20 20
CaseIterable+Random.swift 100.00% 3 3
Data+Random.swift 100.00% 33 33
Date+Random.swift 100.00% 20 20
Optional+Random.swift 100.00% 3 3
SeedableRandomNumberGenerator.swift 100.00% 35 35
String+Random.swift 100.00% 38 38
URL+Random.swift 100.00% 7 7
URLComponents+Random.swift 100.00% 51 51
URLQueryItem+Random.swift 100.00% 14 14
UUID+Random.swift 100.00% 18 18
DevTesting: 99.71% (677 of 679)
File Coverage Covered Lines Executable Lines
ArbitraryError.swift 100.00% 6 6
BinaryFloatingPoint+Random.swift 100.00% 20 20
CaseIterable+Random.swift 100.00% 3 3
CollectionGeneration.swift 100.00% 31 31
Data+Random.swift 100.00% 33 33
Date+Random.swift 100.00% 20 20
DefaultStubValueProviding.swift 100.00% 69 69
Optional+Random.swift 100.00% 3 3
RandomValueGenerating.swift 98.46% 128 130
SeedableRandomNumberGenerator.swift 100.00% 35 35
String+Random.swift 100.00% 38 38
Stub.swift 100.00% 195 195
ThrowingStub+DefaultStubValue.swift 100.00% 6 6
URL+Random.swift 100.00% 7 7
URLComponents+Random.swift 100.00% 51 51
URLQueryItem+Random.swift 100.00% 14 14
UUID+Random.swift 100.00% 18 18

@prachigauriar
prachigauriar merged commit 7df52d2 into main Nov 14, 2026
6 checks passed
@prachigauriar
prachigauriar deleted the default-stub-values branch November 14, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant