Detects if `m.Run()` was actually called in `TestMain`

このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください

Metadata

ID: go-best-practices/missing-run-in-test

Language: Go

Severity: Error

Category: Error Prone

Description

No description found

Non-Compliant Code Examples

package example

import (
    "os"
    "testing"
)

func TestMain(m *testing.M) {
    // Setup code
    doSetup()

    // Missing call to Run() here!
}

Compliant Code Examples

// GOOD: Correct implementation with m.Run()
package example

import (
    "os"
    "testing"
)

func TestMain(m *testing.M) {
    // Setup code
    doSetup()

    // Run the tests
    code := m.Run()
	
	os.Exit(code)
}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Security

PREVIEWING: aleksandr.pasechnik/svls-6807-lambda-fips