Skip to content

Commit 8be04f9

Browse files
committed
fix(testing): should handle Skipped for sub cases
1 parent 6a49847 commit 8be04f9

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ require (
88
github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3
99
github.com/google/go-cmp v0.7.0
1010
golang.org/x/sync v0.17.0
11-
golang.org/x/text v0.29.0
12-
golang.org/x/tools v0.37.0
11+
golang.org/x/text v0.30.0
12+
golang.org/x/tools v0.38.0
1313
)
1414

1515
require (
16-
golang.org/x/mod v0.28.0 // indirect
16+
golang.org/x/mod v0.29.0 // indirect
1717
mvdan.cc/gofumpt v0.9.1 // indirect
1818
)

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1010
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
1111
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
1212
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
13-
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
14-
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
13+
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
14+
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
1515
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
1616
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
17-
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
18-
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
19-
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
20-
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
21-
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
22-
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
17+
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
18+
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
19+
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
20+
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
21+
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
22+
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
2323
mvdan.cc/gofumpt v0.9.1 h1:p5YT2NfFWsYyTieYgwcQ8aKV3xRvFH4uuN/zB2gBbMQ=
2424
mvdan.cc/gofumpt v0.9.1/go.mod h1:3xYtNemnKiXaTh6R4VtlqDATFwBbdXI8lJvH/4qk7mw=

testing/assertions.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import (
77
)
88

99
func Expect[A any](t testing.TB, actual A, matchers ...Matcher[A]) {
10+
if t.Skipped() {
11+
return
12+
}
13+
1014
for i := range matchers {
1115
internal.Expect(t, actual, matchers[i])
1216
}

testing/bdd/bdd.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type TB interface {
1010
Setenv(key, value string)
1111

1212
Skip(args ...any)
13+
Skipped() bool
1314

1415
Context() context.Context
1516
}
@@ -47,21 +48,37 @@ func (t *bddT) Unwrap() *testing.T {
4748
}
4849

4950
func (t *bddT) Given(summary string, setup func(b T)) {
51+
if t.Skipped() {
52+
return
53+
}
54+
5055
t.T.Run("GIVEN "+summary, func(t *testing.T) {
5156
setup(FromT(t))
5257
})
5358
}
5459

5560
func (t *bddT) When(summary string, setup func(b T)) {
61+
if t.Skipped() {
62+
return
63+
}
64+
5665
t.T.Run("WHEN "+summary, func(t *testing.T) {
5766
setup(FromT(t))
5867
})
5968
}
6069

6170
func (t *bddT) Then(summary string, checkers ...Checker) {
71+
if t.Skipped() {
72+
return
73+
}
74+
6275
t.T.Helper()
6376

6477
t.T.Run("THEN "+summary, func(t *testing.T) {
78+
if t.Skipped() {
79+
return
80+
}
81+
6582
t.Helper()
6683

6784
tt := FromT(t)

0 commit comments

Comments
 (0)