Rana
Rana

Reputation: 6154

Testing Internals In Go

The recommended golang test method signature format is:

func TestMxxxx(t *testing.T) {

}

I have noticed if I use 'Testmxxxx', it simply skips the tests. Now, if I have two function in a package, one name myFunc (as private, not exported), and another Myfunc(exported). What will be the approach to write separate test method for each of them?

Upvotes: 2

Views: 81

Answers (1)

Ainar-G
Ainar-G

Reputation: 36199

You can use underscores. E.g.

func Test_mxxxx(t *testing.T) {
    // ...
}

This should run just fine.

Upvotes: 3

Related Questions