Skip to content

Commit c0c2781

Browse files
lvan100lianghuan
authored andcommitted
Docs(gstest): Update documentation comments for the gstest package
1 parent 46c908c commit c0c2781

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

gs/gstest/gstest.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,28 @@
1818
Package gstest provides unit testing utilities for dependency injection in Go-Spring framework.
1919
2020
Key Features:
21-
- Non-critical Dependency Tolerance - Gracefully ignores non-test-target injection failures
22-
via warning logs (enabled by gs.ForceAutowireIsNullable)
23-
- Type-Safe Mocking - Offers MockFor/With methods for compile-time verified mock registration
24-
- Context Lifecycle Management - TestMain automates application context bootstrap/teardown
25-
- Smart Injection Helpers - Provides Get/Wire utilities to simplify test case composition
21+
- Test environment configuration: jobs and servers are disabled, and the "test" profile is automatically activated
22+
- Autowire failure tolerance: non-critical autowiring errors are tolerated so that missing beans do not break tests
23+
- Type-safe mocking: compile-time checked MockFor/With methods for registering mock beans
24+
- Context lifecycle management: TestMain starts and stops the Go-Spring context automatically
25+
- Injection helpers: Get[T](t) and Wire(t, obj) simplify bean retrieval and dependency injection
2626
2727
Usage Pattern:
2828
29-
// Register mocks in init function (executes before TestMain)
29+
// Step 1: Register your mock beans before tests run
30+
// by calling `MockFor[T]().With(obj)` inside an `init()` function.
3031
func init() {
3132
gstest.MockFor[*Dao]().With(&MockDao{})
3233
}
3334
35+
// Step 2: Implement TestMain and invoke `gstest.TestMain(m, opts...)`
36+
// to bootstrap the application context, execute all tests, and then shut it down.
37+
// You can supply `BeforeRun` and `AfterRun` hooks to run code immediately before or after your test suite.
3438
func TestMain(m *testing.M) {
3539
gstest.TestMain(m)
3640
}
3741
42+
// Step 3: Write your test cases and use Get[T](t) or Wire(t, obj) to retrieve beans and inject dependencies.
3843
func TestService(t *testing.T) {
3944
// Retrieve autowired test target
4045
service := gstest.Get[*Service](t)

sdk/mcp/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)