File: globals.go

package info (click to toggle)
golang-github-onsi-ginkgo-v2 2.15.0-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 4,112 kB
  • sloc: javascript: 59; sh: 14; makefile: 7
file content (26 lines) | stat: -rw-r--r-- 1,404 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Package `globals` provides an interface to alter the global state of ginkgo suite.
//
// ginkgo currently registers a few singleton global vars that hold all the
// test blocks and failure management. These vars are global per package, which means
// that only one Suite definition can coexist in one package.
//
// However, there can be some use cases where applications using ginkgo may want to
// have a bit more control about this. For instance, a package may be using ginkgo
// to dynamically generate different tests and groups depending on some configuration.
// In this particular case, if the application wants to test how these different groups
// are generated, they will need access to change these global variables, so they
// can re-generate this global state, and ensure that different configuration generate
// indeed different tests.
//
// Note that this package is not intended to be used as part of normal ginkgo setups, and
// usually, you will never need to worry about the global state of ginkgo
package globals

import "github.com/onsi/ginkgo/v2/internal/global"

// Reset calls `global.InitializeGlobals()` which will basically create a new instance
// of Suite, and therefore, will effectively reset the global variables to the init state.
// This will effectively remove all groups, tests and blocks that were added to the Suite.
func Reset() {
	global.InitializeGlobals()
}