Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
h908714124 authored Dec 11, 2023
1 parent 579adb8 commit 296b306
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ If you inject `Provider<TheBean>`, rather than `TheBean` directly, calling `prov
### Mocking

If you want create a component where some beans are swapped for mock instances, use `@Component(mockBuilder = true)`.
A static `mockBuilder` method will be generated, which returns a builder that can be used to register your mocks.
A static `mockBuilder` method will be generated, which returns a MockBuilder that can be used to register your mocks.
(If your component uses `@Component.Builder`, the generated builder will have a `withMocks` method that returns the MockBuilder.)
[Usage example](https://github.com/jbock-java/modular-thermosiphon):

```java
Expand All @@ -37,10 +38,11 @@ CoffeeLogger mockLogger = new CoffeeLogger("") {
messages.add(msg);
}
};
CoffeeApp.CoffeeShop app = CoffeeApp_CoffeeShop_Impl.mockBuilder()
CoffeeApp.CoffeeShop app = CoffeeApp_CoffeeShop_Impl.builder()
.logLevel("")
.withMocks()
.coffeeLogger(mockLogger)
.build()
.create("");
.build();
app.maker().brew();
assertEquals(List.of(
"~ ~ ~ heating ~ ~ ~",
Expand Down

0 comments on commit 296b306

Please sign in to comment.