Go में किसी विशिष्ट फ़ाइल से एक विशेष टेस्ट या सभी टेस्ट कैसे चलाएँ?
नमस्ते सब! मैंने अभी-अभी Go सीखना शुरू किया है और टेस्ट चलाने में एक समस्या का सामना कर रहा हूँ। मेरे पास निम्नलिखित संरचना वाला एक प्रोजेक्ट है:
```
myproject/
├── main.go
├── handlers.go
├── handlers_test.go
├── utils.go
└── utils_test.go
```
`handlers_test.go` फ़ाइल में मेरे पास कई test functions हैं, और `utils_test.go` में अपने हैं। जब मैं `go test ./...` चलाता हूँ, तो दोनों फ़ाइलों के सभी टेस्ट चलते हैं, और यह सामान्य है। लेकिन कभी-कभी मुझे केवल `handlers_test.go` में मौजूद टेस्ट चलाने की आवश्यकता होती है, बिना `utils_test.go` को छुए।
मैंने `go test handlers_test.go` कमांड आज़माया, लेकिन मुझे compilation error मिलता है, क्योंकि test file में `handlers.go` के functions का उपयोग किया गया है, जो स्वचालित रूप से शामिल नहीं होते। उदाहरण के लिए, `handlers_test.go` में मेरे पास ऐसा कोड है:
```go
package main
import "testing"
func TestHandleRequest(t *testing.T) {
result := HandleRequest("test") // handlers.go का function
if result != "expected" {
t.Errorf("got %v, want %v", result, "expected")
}
}
```