interfaces.go 1.8 KB

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