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 ¶
- Variables
- func AssertAll(fns ...func())
- func AssertArrayEquals(expected, actual any, msg ...any)
- func AssertArrayEqualsDelta(expected, actual, delta any, msg ...any)
- func AssertDoesNotThrow(fn func(), msg ...any)
- func AssertEquals(expected, actual any, msg ...any)
- func AssertEqualsDelta(expected, actual, delta any, msg ...any)
- func AssertFalse(cond bool, msg ...any)
- func AssertInstanceOf[T any](v any, msg ...any) T
- func AssertNotEquals(unexpected, actual any, msg ...any)
- func AssertNotEqualsDelta(unexpected, actual, delta any, msg ...any)
- func AssertNotNull(v any, msg ...any)
- func AssertNotSame(expected, actual any, msg ...any)
- func AssertNull(v any, msg ...any)
- func AssertSame(expected, actual any, msg ...any)
- func AssertThrows[T any](fn func(), msg ...any) (res T)
- func AssertTrue(cond bool, msg ...any)
- func AssumeFalse(cond bool, msg ...any)
- func AssumeTrue(cond bool, msg ...any)
- func Equal(a, b any) bool
- func Fail(msg ...any)
- func FirstSkip(reasons ...string) string
- func IsNull(v any) bool
- func Register(c *Class)
- func SkipIfEnv(name, pattern, reason string) string
- func SkipOnOS(enabled bool, reason string, systems ...string) string
- type AssertionFailed
- type Class
- type Skipped
- type Test
- type TestInfo
Constants ¶
This section is empty.
Variables ¶
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 AssertArrayEqualsDelta ¶
func AssertDoesNotThrow ¶
func AssertDoesNotThrow(fn func(), msg ...any)
func AssertEquals ¶
func AssertEqualsDelta ¶
func AssertFalse ¶
func AssertInstanceOf ¶
func AssertNotEquals ¶
func AssertNotEqualsDelta ¶
func AssertNotNull ¶
func AssertNotSame ¶
func AssertNull ¶
func AssertSame ¶
func AssertThrows ¶
func AssertTrue ¶
func AssumeFalse ¶
func AssumeTrue ¶
func Equal ¶
Equal is Object.equals: the translated equals(Object) (Go Equals(any) bool) when there is one, identity for other objects, value equality otherwise.
func FirstSkip ¶
FirstSkip combines independent annotation conditions without losing later skip reasons.
func IsNull ¶
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).
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).
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