interfaces.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. }
  9. // SetupAllSuite has a SetupSuite method, which will run before the
  10. // tests in the suite are run.
  11. type SetupAllSuite interface {
  12. SetupSuite()
  13. }
  14. // SetupTestSuite has a SetupTest method, which will run before each
  15. // test in the suite.
  16. type SetupTestSuite interface {
  17. SetupTest()
  18. }
  19. // TearDownAllSuite has a TearDownSuite method, which will run after
  20. // all the tests in the suite have been run.
  21. type TearDownAllSuite interface {
  22. TearDownSuite()
  23. }
  24. // TearDownTestSuite has a TearDownTest method, which will run after
  25. // each test in the suite.
  26. type TearDownTestSuite interface {
  27. TearDownTest()
  28. }
  29. // BeforeTest has a function to be executed right before the test
  30. // starts and receives the suite and test names as input
  31. type BeforeTest interface {
  32. BeforeTest(suiteName, testName string)
  33. }
  34. // AfterTest has a function to be executed right after the test
  35. // finishes and receives the suite and test names as input
  36. type AfterTest interface {
  37. AfterTest(suiteName, testName string)
  38. }
  39. // WithStats implements HandleStats, a function that will be executed
  40. // when a test suite is finished. The stats contain information about
  41. // the execution of that suite and its tests.
  42. type WithStats interface {
  43. HandleStats(suiteName string, stats *SuiteInformation)
  44. }