junit

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: EPL-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package junit is the JUnit 5 surface the translated SWT tests (tests/swttests) use: the generated test registry and org.junit.jupiter.api.Assertions/Assumptions. A failed assertion panics *AssertionFailed, a failed assumption *Skipped; cmd/swttest recovers both per test.

Index

Constants

This section is empty.

Variables

View Source
var Classes []*Class

Classes holds every registered class, in registration (Go file init) order.

Functions

func AssertAll

func AssertAll(fns ...func())

AssertAll runs every executable and reports all failures together.

func AssertArrayEquals

func AssertArrayEquals(expected, actual any, msg ...any)

func AssertArrayEqualsDelta

func AssertArrayEqualsDelta(expected, actual, delta any, msg ...any)

func AssertDoesNotThrow

func AssertDoesNotThrow(fn func(), msg ...any)

func AssertEquals

func AssertEquals(expected, actual any, msg ...any)

func AssertEqualsDelta

func AssertEqualsDelta(expected, actual, delta any, msg ...any)

func AssertFalse

func AssertFalse(cond bool, msg ...any)

func AssertInstanceOf

func AssertInstanceOf[T any](v any, msg ...any) T

func AssertNotEquals

func AssertNotEquals(unexpected, actual any, msg ...any)

func AssertNotEqualsDelta

func AssertNotEqualsDelta(unexpected, actual, delta any, msg ...any)

func AssertNotNull

func AssertNotNull(v any, msg ...any)

func AssertNotSame

func AssertNotSame(expected, actual any, msg ...any)

func AssertNull

func AssertNull(v any, msg ...any)

func AssertSame

func AssertSame(expected, actual any, msg ...any)

func AssertThrows

func AssertThrows[T any](fn func(), msg ...any) (res T)

func AssertTrue

func AssertTrue(cond bool, msg ...any)

func AssumeFalse

func AssumeFalse(cond bool, msg ...any)

func AssumeTrue

func AssumeTrue(cond bool, msg ...any)

func Equal

func Equal(a, b any) bool

Equal is Object.equals: the translated equals(Object) (Go Equals(any) bool) when there is one, identity for other objects, value equality otherwise.

func Fail

func Fail(msg ...any)

func IsNull

func IsNull(v any) bool

IsNull is Java's null: a nil pointer/slice/map/func/interface, and "" - the port's stand-in for a null String (Go's string has no nil).

func Register

func Register(c *Class)

func SkipIfEnv

func SkipIfEnv(name, pattern, reason string) string

SkipIfEnv is @DisabledIfEnvironmentVariable(named, matches, disabledReason): reason when the variable is set and fully matches, else "".

Types

type AssertionFailed

type AssertionFailed struct{ Message string }

AssertionFailed is the panic value of a failed assertion or fail().

func (*AssertionFailed) Error

func (e *AssertionFailed) Error() string

type Class

type Class struct {
	Name                  string
	New                   func() any
	BeforeAll, AfterAll   []func()
	BeforeEach, AfterEach []func(instance any)
	Tests                 []Test
}

Class is one test class: New creates a fresh instance per test, as JUnit's default lifecycle.

type Skipped

type Skipped struct{ Reason string }

Skipped is the panic value of a failed assumption (assumeTrue/assumeFalse).

func (*Skipped) Error

func (e *Skipped) Error() string

type Test

type Test struct {
	Name    string
	Tags    []string
	Skip    string        // non-empty: not run, with this reason
	Timeout time.Duration // 0: the runner's default
	Run     func(instance any)
}

Test is one test method (a @ParameterizedTest is expanded into one Test per argument).

type TestInfo

type TestInfo struct{ Method string }

TestInfo is JUnit's TestInfo for the test being run; Current is set by the runner before @BeforeEach.

var Current *TestInfo

func (*TestInfo) GetDisplayName

func (t *TestInfo) GetDisplayName() string

func (*TestInfo) GetTestMethod

func (t *TestInfo) GetTestMethod() *jrt.Optional

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL