In the code provided the difference can be seen by uncommenting the t.Parallel() allowing the failed second test to pass.
func TestMain(m *testing.M) {
RegisterFailHandler(sweet.GomegaFail)
sweet.Run(m, func(s *sweet.S){
s.AddSuite(&checkout{})
})
}
func main() {
fmt.Println("vim-go")
}
func shopCheckout(count int) int {
count += (count * 2)
return count
}
func (s *checkout) TestAppleShopCheckout(t sweet.T) {
tcs := []struct {
testName string
userName string
count int
expectedTo types.GomegaMatcher
}{
{
testName: "valid-price",
userName: "Bob",
count: 15,
expectedTo: Equal(30),
},
{
testName: "valid-price",
userName: "Gina",
count: 12,
expectedTo: Equal(44),
},
}
for _, tc := range tcs {
tc := tc
t.Run(tc.testName, func(t sweet.T) {
//t.Parallel()
got := shopCheckout(tc.count)
Expect(got).To(tc.expectedTo)
})
}
}
Expected failing subtests pass when using t.Parallel
In the code provided the difference can be seen by uncommenting the t.Parallel() allowing the failed second test to pass.