Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Support for overriding `t.Chdir` and `t.Cleanup`.
- Access to `testing.T` which invoked a suite through reflection.

### Changed

Expand Down
16 changes: 9 additions & 7 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ func (r *runner[Suite, T]) runSuite(
tests := r.collectTests(testingT, caller)

suiteInfo := testoreflect.SuiteInfo{
Name: r.suiteName,
Caller: testingT.Name(),
Value: suite,
Name: r.suiteName,
Caller: testingT.Name(),
TestingT: testingT,
Value: suite,
}

return testingT.Run(r.suiteName, func(testingT *testing.T) {
Expand Down Expand Up @@ -196,10 +197,11 @@ func (r *runner[Suite, T]) runSuiteTests(t T, s Suite, tests suiteTests[Suite, T
s.BeforeAll(t)

suiteInfo := testoreflect.SuiteInfo{
Name: t.unwrap().reflection.Suite.Name,
Caller: t.unwrap().reflection.Suite.Caller,
Value: s,
Hooks: t.unwrap().reflection.Suite.Hooks,
Name: t.unwrap().reflection.Suite.Name,
Caller: t.unwrap().reflection.Suite.Caller,
TestingT: t.unwrap().reflection.Suite.TestingT,
Value: s,
Hooks: t.unwrap().reflection.Suite.Hooks,
}

allTests := r.applyPlan(
Expand Down
8 changes: 8 additions & 0 deletions testoreflect/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ type SuiteInfo struct {
// which this suite was run.
Caller string

// TestingT is the [testing.T] of the caller.
//
// func TestFoo(t *testing.T) {
// testo.RunSuite(t, new(Suite))
// // ^ that t
// }
TestingT TestingT

// Value holds suite value.
Value any

Expand Down
Loading