swiftlang / swift-testing

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

Public API for observing test events #469

Open ypopovych opened 5 months ago

ypopovych commented 5 months 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 5 months 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 5 months ago

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

Tracked internally as rdar://129609023

grynspan commented 5 months 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?

grynspan commented 3 months ago

Experimental implementation on branch jgrynspan/469-observer-attribute.