github.com/ninadingole/gotest-ls@v0.0.3/tests/table_test.go (about)

     1  package tests_test
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func Test(t *testing.T) {
     8  	t.Parallel()
     9  
    10  	msg := "Hello, world!"
    11  
    12  	t.Run("mixed subtest 1", func(t *testing.T) {
    13  		t.Parallel()
    14  		t.Log(msg)
    15  	})
    16  
    17  	tests := []struct {
    18  		name string
    19  		calc func() int
    20  		want int
    21  	}{
    22  		{
    23  			name: "5 + 5 = 10",
    24  			calc: func() int {
    25  				return 5 + 5
    26  			},
    27  			want: 10,
    28  		},
    29  		{
    30  			name: "5 - 5 = 0",
    31  			calc: func() int {
    32  				return 5 - 2
    33  			},
    34  			want: 3,
    35  		},
    36  	}
    37  	for _, tt := range tests {
    38  		tt := tt
    39  		t.Run(tt.name, func(t *testing.T) {
    40  			t.Parallel()
    41  
    42  			if got := tt.calc(); got != tt.want {
    43  				t.Errorf("got %d, want %d", got, tt.want)
    44  			}
    45  		})
    46  	}
    47  
    48  	t.Run("mixed test 2", func(t *testing.T) {
    49  		t.Parallel()
    50  		t.Log("This is a subtest")
    51  	})
    52  }