// runTestsInternal does the real work of RunTests, which simply wraps it in a
// sync.Once.
runTestsInternal does the real work of RunTests, which simply wraps it in a
sync.Once.
// runTestsInternal does the real work of RunTests which simply wraps it in a // sync . Once .
func runTestsInternal(t *testing.T) {
	for _, suite := range testSuites {
		val := reflect.ValueOf(suite)
		typ := val.Type()
		suiteName := typ.Elem().Name()
		testMethods := filterMethods(suiteName, getMethodsInSourceOrder(typ))
		if len(testMethods) == 0 {
			continue
		}
		fmt.Printf("[----------] Running tests from %s\n", suiteName)
		runMethodIfExists(val, "SetUpTestSuite")
		for _, method := range testMethods {
			fmt.Printf("[ RUN      ] %s.%s\n", suiteName, method.Name)
			startTime := time.Now()
			failures := runTest(suite, method)
			runDuration := time.Since(startTime)
			for _, record := range failures {
				t.Fail()
				userErrorSection := ""
				if record.UserError != "" {
					userErrorSection = record.UserError + "\n"
				}
				fmt.Printf(
					"%s:%d:\n%s\n%s\n",
					record.FileName,
					record.LineNumber,
					record.GeneratedError,
					userErrorSection)
			}
			bannerMessage := "[       OK ]"
			if len(failures) != 0 {
				bannerMessage = "[  FAILED  ]"
			}
			var timeMessage string
			if runDuration >= 25*time.Millisecond {
				timeMessage = fmt.Sprintf(" (%s)", runDuration.String())
			}
			fmt.Printf(
				"%s %s.%s%s\n",
				bannerMessage,
				suiteName,
				method.Name,
				timeMessage)
		}
		runMethodIfExists(val, "TearDownTestSuite")
		fmt.Printf("[----------] Finished with tests from %s\n", suiteName)
	}
}
func runTestsInternal ( t * testing . T ) { for _ , suite := range testSuites { val := reflect . ValueOf ( suite ) typ := val . Type ( ) suiteName := typ . Elem ( ) . Name ( ) testMethods := filterMethods ( suiteName , getMethodsInSourceOrder ( typ ) ) if len ( testMethods ) == 0 { continue } fmt . Printf ( " \n " , suiteName ) runMethodIfExists ( val , " " ) for _ , method := range testMethods { fmt . Printf ( " \n " , suiteName , method . Name ) startTime := time . Now ( ) failures := runTest ( suite , method ) runDuration := time . Since ( startTime ) for _ , record := range failures { t . Fail ( ) userErrorSection := " " if record . UserError != " " { userErrorSection = record . UserError + " \n " } fmt . Printf ( " \n \n \n " , record . FileName , record . LineNumber , record . GeneratedError , userErrorSection ) } bannerMessage := " " if len ( failures ) != 0 { bannerMessage = " " } var timeMessage string if runDuration >= 25 * time . Millisecond { timeMessage = fmt . Sprintf ( " " , runDuration . String ( ) ) } fmt . Printf ( " \n " , bannerMessage , suiteName , method . Name , timeMessage ) } runMethodIfExists ( val , " " ) fmt . Printf ( " \n " , suiteName ) } }
runTestsInternal does the real work of RunTests, which simply wraps it in a
sync.Once.
runTestsInternal does the real work of RunTests which simply wraps it in a sync . Once .
// Process each registered suite. // Grab methods for the suite, filtering them to just the ones that we // don't need to skip. // Is there anything left to do? // Run the SetUpTestSuite method, if any. // Run each method. // Print a banner for the start of this test. // Run the test. // Print any failures, and mark the test as having failed if there are any. // Print a banner for the end of the test. // Print a summary of the time taken, if long enough. // Run the TearDownTestSuite method, if any.