Sobes.tech
Junior — Middle

Come si può eseguire un insieme specifico di scenari di test?

sobes.tech AI

Risposta dell'AI

In Go, per eseguire un insieme specifico di scenari di test, puoi usare il pacchetto testing e avviare i test con il comando go test filtrando per il nome del test.

Ad esempio, se hai diversi test:

func TestAdd(t *testing.T) {
    // test per la funzione Add
}

func TestSubtract(t *testing.T) {
    // test per la funzione Subtract
}

Per eseguire solo i test il cui nome contiene Add, usa:

go test -run Add

Puoi anche creare file di test con diversi set di test e eseguirli separatamente o usare tag di compilazione per raggruppare i test.