Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added

- `testo.Plugins` function to get plugin instances of a given `T`.

## [1.8.0] - 2026-08-30

### Added
Expand Down
54 changes: 48 additions & 6 deletions t.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,18 +620,60 @@ func (t *T) logPlugins() {
func Reflect(t CommonT) testoreflect.Reflection {
t.Helper()

internal := t.unwrap()
u := t.unwrap()

info := internal.reflection.Load()
info := u.reflection.Load()

info.FailureSource = internal.failureSource.Load()
info.FailureKind = internal.failureKind.Load()
info.HasFatalSubtest = internal.hasFatalSubtest.Load()
info.TestingT = internal.testingT
info.FailureSource = u.failureSource.Load()
info.FailureKind = u.failureKind.Load()
info.HasFatalSubtest = u.hasFatalSubtest.Load()
info.TestingT = u.testingT

return info
}

// Plugins returns information about installed plugins
// in the given t instance.
//
// Returned slice follows plugins declaration order.
//
// For example:
//
// type T struct{
// *testo.T
// *PluginBar
// *PluginFoo
// *PluginAllure
// }
//
// func (*Suite) Test(t T) {
// testo.Plugins(t)
// }
//
// Would return:
//
// []testoplugin.Plugin{*PluginBar(...), *PluginFoo(...), *PluginAllure(...)}
//
// NOTE: this function returns pointers to an actual plugin instances, so calling
// their methods is equivalent to calling T's methods.
func Plugins(t CommonT) []testoplugin.Plugin {
t.Helper()

u := t.unwrap()

plugins := make([]testoplugin.Plugin, 0, len(u.plugins))

for _, typ := range u.pluginOrder {
if typ == reflect.TypeFor[*T]() {
continue
}

plugins = append(plugins, u.plugins[typ])
}

return plugins
}

type atomicInt[T ~int | ~int8 | ~int32 | ~int64] atomic.Int64

func (a *atomicInt[T]) Load() T {
Expand Down