@@ -27,7 +27,7 @@ func TestSuiteRequireTwice(t *testing.T) {
27
27
ok := testing .RunTests (
28
28
allTestsFilter ,
29
29
[]testing.InternalTest {{
30
- Name : "TestSuiteRequireTwice " ,
30
+ Name : t . Name () + "/SuiteRequireTwice " ,
31
31
F : func (t * testing.T ) {
32
32
suite := new (SuiteRequireTwice )
33
33
Run (t , suite )
@@ -104,31 +104,31 @@ func TestSuiteRecoverPanic(t *testing.T) {
104
104
ok := true
105
105
panickingTests := []testing.InternalTest {
106
106
{
107
- Name : "TestPanicInSetupSuite " ,
107
+ Name : t . Name () + "/InSetupSuite " ,
108
108
F : func (t * testing.T ) { Run (t , & panickingSuite {panicInSetupSuite : true }) },
109
109
},
110
110
{
111
- Name : "TestPanicInSetupTest " ,
111
+ Name : t . Name () + "/InSetupTest " ,
112
112
F : func (t * testing.T ) { Run (t , & panickingSuite {panicInSetupTest : true }) },
113
113
},
114
114
{
115
- Name : "TestPanicInBeforeTest " ,
115
+ Name : t . Name () + "InBeforeTest " ,
116
116
F : func (t * testing.T ) { Run (t , & panickingSuite {panicInBeforeTest : true }) },
117
117
},
118
118
{
119
- Name : "TestPanicInTest " ,
119
+ Name : t . Name () + "/InTest " ,
120
120
F : func (t * testing.T ) { Run (t , & panickingSuite {panicInTest : true }) },
121
121
},
122
122
{
123
- Name : "TestPanicInAfterTest " ,
123
+ Name : t . Name () + "/InAfterTest " ,
124
124
F : func (t * testing.T ) { Run (t , & panickingSuite {panicInAfterTest : true }) },
125
125
},
126
126
{
127
- Name : "TestPanicInTearDownTest " ,
127
+ Name : t . Name () + "/InTearDownTest " ,
128
128
F : func (t * testing.T ) { Run (t , & panickingSuite {panicInTearDownTest : true }) },
129
129
},
130
130
{
131
- Name : "TestPanicInTearDownSuite " ,
131
+ Name : t . Name () + "/InTearDownSuite " ,
132
132
F : func (t * testing.T ) { Run (t , & panickingSuite {panicInTearDownSuite : true }) },
133
133
},
134
134
}
@@ -451,7 +451,7 @@ func TestSuiteLogging(t *testing.T) {
451
451
suiteLoggingTester := new (SuiteLoggingTester )
452
452
capture := StdoutCapture {}
453
453
internalTest := testing.InternalTest {
454
- Name : "SomeTest " ,
454
+ Name : t . Name () + "/SuiteLoggingTester " ,
455
455
F : func (subT * testing.T ) {
456
456
Run (subT , suiteLoggingTester )
457
457
},
@@ -552,14 +552,15 @@ func (s *suiteWithStats) TestPanic() {
552
552
func TestSuiteWithStats (t * testing.T ) {
553
553
suiteWithStats := new (suiteWithStats )
554
554
555
- testing .RunTests (allTestsFilter , []testing.InternalTest {
555
+ suiteSuccess := testing .RunTests (allTestsFilter , []testing.InternalTest {
556
556
{
557
- Name : "WithStats " ,
557
+ Name : t . Name () + "/suiteWithStats " ,
558
558
F : func (t * testing.T ) {
559
559
Run (t , suiteWithStats )
560
560
},
561
561
},
562
562
})
563
+ require .False (t , suiteSuccess , "suiteWithStats should report test failure because of panic in TestPanic" )
563
564
564
565
assert .True (t , suiteWithStats .wasCalled )
565
566
assert .NotZero (t , suiteWithStats .stats .Start )
@@ -596,7 +597,7 @@ func TestFailfastSuite(t *testing.T) {
596
597
ok := testing .RunTests (
597
598
allTestsFilter ,
598
599
[]testing.InternalTest {{
599
- Name : "TestFailfastSuite " ,
600
+ Name : t . Name () + "/FailfastSuite " ,
600
601
F : func (t * testing.T ) {
601
602
Run (t , s )
602
603
},
@@ -669,23 +670,24 @@ func (s *subtestPanicSuite) TearDownSubTest() {
669
670
}
670
671
671
672
func (s * subtestPanicSuite ) TestSubtestPanic () {
672
- s .Run ("subtest" , func () {
673
+ ok := s .Run ("subtest" , func () {
673
674
panic ("panic" )
674
675
})
676
+ s .False (ok , "subtest failure is expected" )
675
677
}
676
678
677
679
func TestSubtestPanic (t * testing.T ) {
678
680
suite := new (subtestPanicSuite )
679
681
ok := testing .RunTests (
680
682
allTestsFilter ,
681
683
[]testing.InternalTest {{
682
- Name : "TestSubtestPanic " ,
684
+ Name : t . Name () + "/subtestPanicSuite " ,
683
685
F : func (t * testing.T ) {
684
686
Run (t , suite )
685
687
},
686
688
}},
687
689
)
688
- assert .False (t , ok )
690
+ assert .False (t , ok , "TestSubtestPanic/subtest should make the testsuite fail" )
689
691
assert .True (t , suite .inTearDownSubTest )
690
692
assert .True (t , suite .inTearDownTest )
691
693
assert .True (t , suite .inTearDownSuite )
0 commit comments