Go test Command: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 8: Line 8:
The <code>go test</code> runs in two modes: [[#Local_Directory_Mode|local directory mode]] and [[#Package_List_Mode|package list mode]].
The <code>go test</code> runs in two modes: [[#Local_Directory_Mode|local directory mode]] and [[#Package_List_Mode|package list mode]].
==Local Directory Mode==
==Local Directory Mode==
<code>go test</code> runs in '''local directory mode''' when it is invoked with no package argument. In this mode, <code>go test</code> compiles the package sources and tests found in the current directory, and then runs the resulting test binary. [[#Caching|Caching]] is disabled.
<code>go test</code> runs in '''local directory mode''' when it is invoked with no package argument. In this mode, <code>go test</code> compiles the package sources and tests found in the current directory, and then runs the resulting test binary. [[#Caching|Caching]] is disabled. After the package test finishes <font color=darkkhaki>(what if there are multiple packages?)</font>, the runtime print a summary line with the test status ('ok', 'FAIL', package name and elapsed time).


==Package List Mode==
==Package List Mode==
=Caching=
=Caching=

Revision as of 22:54, 8 January 2024

Internal

Overview

The test command runs tests. The shared flags described here apply:

Shared Flags

For more details on testing, in general, see:

Go Testing

go test Execution Modes

The go test runs in two modes: local directory mode and package list mode.

Local Directory Mode

go test runs in local directory mode when it is invoked with no package argument. In this mode, go test compiles the package sources and tests found in the current directory, and then runs the resulting test binary. Caching is disabled. After the package test finishes (what if there are multiple packages?), the runtime print a summary line with the test status ('ok', 'FAIL', package name and elapsed time).

Package List Mode

Caching