Help us shape the future of Go! Take the 2026 Go Developer Survey

testutil

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockBinder

type MockBinder struct{}

MockBinder is a test double for binder.IBinder that returns a SecurityException reply from every Transact call. This allows testing generated proxy methods without a real binder driver.

func NewMockBinder

func NewMockBinder() *MockBinder

NewMockBinder creates a new MockBinder.

func (*MockBinder) Cookie

func (m *MockBinder) Cookie() uintptr

Cookie returns 0 (mock has no local binder cookie).

func (*MockBinder) Handle

func (m *MockBinder) Handle() uint32

Handle returns a fixed handle value of 42.

func (*MockBinder) Identity

func (m *MockBinder) Identity() binder.CallerIdentity

Identity returns a zero-value CallerIdentity since the mock has no real caller.

func (*MockBinder) IsAlive

func (m *MockBinder) IsAlive(_ context.Context) bool

IsAlive always returns true for the mock.

func (*MockBinder) LinkToDeath

func (m *MockBinder) LinkToDeath(
	_ context.Context,
	_ binder.DeathRecipient,
) error

LinkToDeath is a no-op for the mock.

func (*MockBinder) ResolveCode

func (m *MockBinder) ResolveCode(
	_ context.Context,
	_ string,
	_ string,
) (binder.TransactionCode, error)

ResolveCode always returns FirstCallTransaction for the mock. The mock doesn't care about transaction codes — it returns SecurityException regardless.

func (*MockBinder) Transact

Transact returns a reply parcel containing a SecurityException status.

func (*MockBinder) Transport

func (m *MockBinder) Transport() binder.VersionAwareTransport

Transport returns nil since there is no underlying transport.

func (*MockBinder) UnlinkToDeath

func (m *MockBinder) UnlinkToDeath(
	_ context.Context,
	_ binder.DeathRecipient,
) error

UnlinkToDeath is a no-op for the mock.

type SmokeOption

type SmokeOption func(*smokeConfig)

SmokeOption configures SmokeTestAllMethods behavior.

func WithMethodFilter

func WithMethodFilter(filter func(string) bool) SmokeOption

WithMethodFilter sets a predicate that decides whether a method should be tested. Methods for which the filter returns false are skipped.

type SmokeResult

type SmokeResult struct {
	Total    int
	Passed   int
	Panicked int
	Failed   int
}

SmokeResult summarizes the outcome of SmokeTestAllMethods.

func SmokeTestAllMethods

func SmokeTestAllMethods(
	t *testing.T,
	proxy any,
	opts ...SmokeOption,
) SmokeResult

SmokeTestAllMethods calls every exported method on proxy with zero-value arguments and classifies the results. Each method is run as a t.Run sub-test. Panics (e.g. nil interface dereference) are caught and counted, not propagated.

Jump to

Keyboard shortcuts

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