---
title: "0026-TASK-LOCAL-TEST-TRAIT: TaskLocal test trait"
framework: Swift Evolution Proposals
role: article
path: swift-evolution/testing/0026-task-local-test-trait
---

# 0026-TASK-LOCAL-TEST-TRAIT: TaskLocal test trait

* Proposal: [ST-0026](0026-task-local-test-trait.md)
* Authors: [Brandon Williams](https://github.com/mbrandonw), [Stephen Celis](https://github.com/stephencelis)
* Review Manager: [Stuart Montgomery](https://github.com/stmontgomery)
* Status: **Active Review (July 17...July 27, 2026)**
* Implementation: [swiftlang/swift-testing#1764](https://github.com/swiftlang/swift-testing/pull/1764)
* Review: ([pitch](https://forums.swift.org/t/pitch-add-a-tasklocal-trait-to-swift-testing/87603)) ([review](https://forums.swift.org/t/st-0026-tasklocal-test-trait/88358))

## Source compatibility

The proposed APIs are purely additive.

## Alternatives considered

A few other spellings have been proposed:

* `$isEnabled.set(true)` * `.withValue(true, for: $isEnabled)` * `.binding($isEnabled, to: true)`

We prefer the naming `.taskLocal(_:_:)` because it unambiguously refers to task locals, and keeps the arguments in the same order as `withValue`.

We could also decide to not add the trait since technically it is possible to implement its  functionality manually for each task local.

## Future directions

If Swift macros gain the ability to see symbols defined by other macros, this proposed API would become usable in more contexts/situations.
