Setup and BeforeEach are supposed to setup environment before each Test Group and Sub Test. If these methods assert then it is expected that no SubTests are executed in the group. But go test still proceeds further and causes incorrect behaviour reporting.
In following example (both // Sample 1 and // Sample 2), SubTestSample1 should never get executed but in reality it does.
I am using -failfast flag while running go test
/usr/local/go/bin/go test -timeout 30s -run ^TestSampleTests$ automation -failfast
func setupNetwork(t *testing.T) {
assert.Nil(t, nil)
}
type MyTests struct {}
// Sample 1
func (s * MyTests) Setup(t *testing.T) {
setupNetwork()
}
// Sample 2
func (s * MyTests) Setup(t *testing.T) {
assert.Nil(t, nil)
}
func (s *MyTests) Teardown(t *testing.T) {}
func (s *MyTests) BeforeEach(t *testing.T) {}
func (s *MyTests) AfterEach(t *testing.T) {}
func (s *MyTests) SubTestSample1(t *testing.T) {
}
func TestSampleTests(t *testing.T) {
gtest.RunSubTests(t, &MyTests{})
}
gtest v1.0.0
Setup and BeforeEach are supposed to setup environment before each Test Group and Sub Test. If these methods assert then it is expected that no SubTests are executed in the group. But go test still proceeds further and causes incorrect behaviour reporting.
In following example (both
// Sample 1
and// Sample 2
),SubTestSample1
should never get executed but in reality it does.I am using -failfast flag while running go test
/usr/local/go/bin/go test -timeout 30s -run ^TestSampleTests$ automation -failfast