Harry
Harry

Reputation: 1337

How example can be run in test?

I'm trying to run example in test. However after running, warning is shown. testing: warning: no tests to run

This example code includes comment // Output comment.

func ExampleMethod1() {
    fmt.Printf("result: %x", Method1())
    // Output: xxxx
}

What is wrong? When running test, I executed like this. go test -v xxxx_test.go

Thanks.

Harry

Upvotes: 1

Views: 163

Answers (1)

Harry
Harry

Reputation: 1337

After this post, I found it.

My xxx_test.go file didn't include Testxxx func at all. xxx_test.go fires need it at least one. After adding Testxxx func besides Example, example code worked!

Thanks!!

Upvotes: 1

Related Questions