MCPcopy Create free account
hub / github.com/goadesign/goa / TestWithSubtests

Function TestWithSubtests

codegen/testutil/example_test.go:40–71  ·  view source on GitHub ↗

Example: Testing with subtests

(t *testing.T)

Source from the content-addressed store, hash-verified

38
39// Example: Testing with subtests
40func TestWithSubtests(t *testing.T) {
41 testCases := []struct {
42 name string
43 generate func() string
44 golden string
45 }{
46 {
47 name: "simple",
48 generate: generateSimpleCode,
49 golden: "simple.go.golden",
50 },
51 {
52 name: "complex",
53 generate: generateComplexCode,
54 golden: "complex.go.golden",
55 },
56 {
57 name: "with_errors",
58 generate: generateCodeWithErrors,
59 golden: "errors.go.golden",
60 },
61 }
62
63 for _, tc := range testCases {
64 t.Run(tc.name, func(t *testing.T) {
65 code := tc.generate()
66 // Create new GoldenFile for subtest
67 subGF := testutil.NewGoldenFile(t, "testdata/golden")
68 subGF.StringContent(code).Path(tc.golden).CompareContent()
69 })
70 }
71}
72
73// Example: Parallel golden file updates
74func TestParallelUpdates(t *testing.T) {

Callers

nothing calls this directly

Calls 5

StringContentMethod · 0.95
NewGoldenFileFunction · 0.92
CompareContentMethod · 0.80
PathMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected