@@ -107,7 +107,9 @@ func (test *tscInput) writeTestSourceFile(scenario string, editOps [][]capturedE
107107 if err := os .MkdirAll (outDir , 0o755 ); err != nil {
108108 panic (fmt .Errorf ("tsctests: failed to create %s: %w" , outDir , err ))
109109 }
110- outPath := filepath .Join (outDir , funcName + "_test.go" )
110+ testFileName := funcName + "_test.go"
111+ testFileName = strings .ToLower (testFileName [:1 ]) + testFileName [1 :]
112+ outPath := filepath .Join (outDir , testFileName )
111113 if existing , err := os .ReadFile (outPath ); err == nil && string (existing ) == source {
112114 return
113115 }
@@ -134,7 +136,7 @@ func (test *tscInput) renderTestSource(scenario string, funcName string, editOps
134136 b .WriteString (")\n " )
135137 b .WriteString ("\n " )
136138
137- fmt .Fprintf (& b , "func %s(t *testing.T) {\n " , funcName )
139+ fmt .Fprintf (& b , "func Test %s(t *testing.T) {\n " , funcName )
138140 b .WriteString ("\t test := &tsctests.TestSpec{\n " )
139141 fmt .Fprintf (& b , "\t \t Scenario: %s,\n " , strconv .Quote (scenario ))
140142 fmt .Fprintf (& b , "\t \t SubScenario: %s,\n " , strconv .Quote (test .subScenario ))
@@ -313,15 +315,19 @@ var (
313315// appends a short hash suffix when the sanitized result would be ambiguous.
314316func makeTestFuncName (parts ... string ) string {
315317 var b strings.Builder
316- b .WriteString ("Test" )
317318 joinedRaw := strings .Join (parts , "/" )
318- for _ , p := range parts {
319+ for i , p := range parts {
319320 sanitized := identSanitizer .ReplaceAllString (p , "_" )
320321 sanitized = strings .Trim (sanitized , "_" )
321322 if sanitized == "" {
322323 continue
323324 }
324- b .WriteByte ('_' )
325+ if i != 0 {
326+ b .WriteByte ('_' )
327+ } else {
328+ sanitized = strings .ToUpper (sanitized [:1 ]) + sanitized [1 :] // Test function must start with uppercase
329+ }
330+
325331 b .WriteString (sanitized )
326332 }
327333
0 commit comments