interfaces.go (1795B)
1 package suite 2 3 import "testing" 4 5 // TestingSuite can store and return the current *testing.T context 6 // generated by 'go test'. 7 type TestingSuite interface { 8 T() *testing.T 9 SetT(*testing.T) 10 SetS(suite TestingSuite) 11 } 12 13 // SetupAllSuite has a SetupSuite method, which will run before the 14 // tests in the suite are run. 15 type SetupAllSuite interface { 16 SetupSuite() 17 } 18 19 // SetupTestSuite has a SetupTest method, which will run before each 20 // test in the suite. 21 type SetupTestSuite interface { 22 SetupTest() 23 } 24 25 // TearDownAllSuite has a TearDownSuite method, which will run after 26 // all the tests in the suite have been run. 27 type TearDownAllSuite interface { 28 TearDownSuite() 29 } 30 31 // TearDownTestSuite has a TearDownTest method, which will run after 32 // each test in the suite. 33 type TearDownTestSuite interface { 34 TearDownTest() 35 } 36 37 // BeforeTest has a function to be executed right before the test 38 // starts and receives the suite and test names as input 39 type BeforeTest interface { 40 BeforeTest(suiteName, testName string) 41 } 42 43 // AfterTest has a function to be executed right after the test 44 // finishes and receives the suite and test names as input 45 type AfterTest interface { 46 AfterTest(suiteName, testName string) 47 } 48 49 // WithStats implements HandleStats, a function that will be executed 50 // when a test suite is finished. The stats contain information about 51 // the execution of that suite and its tests. 52 type WithStats interface { 53 HandleStats(suiteName string, stats *SuiteInformation) 54 } 55 56 // SetupSubTest has a SetupSubTest method, which will run before each 57 // subtest in the suite. 58 type SetupSubTest interface { 59 SetupSubTest() 60 } 61 62 // TearDownSubTest has a TearDownSubTest method, which will run after 63 // each subtest in the suite have been run. 64 type TearDownSubTest interface { 65 TearDownSubTest() 66 }