swift-testing icon indicating copy to clipboard operation
swift-testing copied to clipboard

Public API for observing test events

Open ypopovych opened this issue 1 year ago • 4 comments

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 avatar Jun 11 '24 18:06 ypopovych

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.

ypopovych avatar Jun 12 '24 09:06 ypopovych

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

Tracked internally as rdar://129609023

stmontgomery avatar Jun 12 '24 17:06 stmontgomery

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 avatar Jun 14 '24 10:06 grynspan

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

grynspan avatar Jul 26 '24 13:07 grynspan