apple / swift-testing

A modern, expressive testing package for Swift
Apache License 2.0
1.47k stars 52 forks source link

Public API for observing test events #469

Open ypopovych opened 2 weeks ago

ypopovych commented 2 weeks ago

Description

It will be good to have a way to observe testing process. Analog to the XCTestObservation and XCTestObservationCenter in the XCTest

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

swift-testing version/commit hash

No response

Swift & OS version (output of swift --version && uname -a)

No response

ypopovych commented 2 weeks ago

Seems as library has Event API already. API to register event handlers should be added (maybe as dynamic library through command-line arguments) or through some macros in code.

stmontgomery commented 2 weeks ago

I agree this is something we want to expose as public API eventually.

Tracked internally as rdar://129609023

grynspan commented 2 weeks ago

We have a lot of the moving parts already. What we don't have is a way to hook into the event stream arbitrarily.

Currently, there is support for streaming JSON descriptions of events to an arbitrary file when using swift test. Xcode doesn't offer a way to enable that functionality, but it could be done.

Would that be sufficient for your use case?