Merged
Conversation
86f612e to
8151ee7
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the bosk-junit injection mechanism to support class-level field injection (via @Injected fields and a new @InjectFields class template), enabling more composable test parameterization than JUnit’s @ParameterizedClass.
Changes:
- Introduces
Injector(replacingParameterInjector) with unified support for parameters and fields (AnnotatedElement-based). - Adds field injection support (
@Injected,@InjectFields,FieldInjectionContextProvider) and shared branching logic (ParameterInjectionSupport). - Refactors multiple test suites (boson, mongo, sql, testing, core) to use
@InjectFrom+ field injection instead of JUnit@ParameterizedClass, and adds new injectors/docs.
Reviewed changes
Copilot reviewed 46 out of 46 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| boson/src/test/java/works/bosk/boson/types/DataTypeHasWildcardsTest.java | Migrates test injectors to the new Injector API. |
| boson/src/test/java/works/bosk/boson/codec/io/JsonSuiteTest.java | Replaces @ParameterizedClass usage with @InjectFrom. |
| boson/src/test/java/works/bosk/boson/codec/io/JsonReaderValidateSyntaxTest.java | Switches from constructor/class parameterization to field injection + standard @Test lifecycle. |
| boson/src/test/java/works/bosk/boson/codec/io/JsonReaderValidateSyntaxInjector.java | Adds dedicated injector supplying validate-syntax reader factories. |
| boson/src/test/java/works/bosk/boson/codec/io/JsonReaderInvalidTokenTest.java | Replaces @ParameterizedClass usage with @InjectFrom. |
| boson/src/test/java/works/bosk/boson/codec/io/JsonReaderInjector.java | Adds shared JsonReader supplier injector for reader-based test suites. |
| boson/src/test/java/works/bosk/boson/codec/io/JsonReaderHappyTest.java | Replaces @ParameterizedClass usage with @InjectFrom. |
| boson/src/test/java/works/bosk/boson/codec/io/AbstractJsonReaderTest.java | Converts class-level parameterization to injected field (Function<String, JsonReader>). |
| boson/src/test/java/works/bosk/boson/codec/SettingsInjector.java | Updates settings injector to Injector API. |
| boson/src/test/java/works/bosk/boson/codec/RoundTripTest.java | Migrates from constructor parameterization to @InjectFields + injected settings. |
| boson/src/test/java/works/bosk/boson/codec/PrimitiveTypeInjector.java | Updates primitive type injector to Injector API. |
| boson/src/test/java/works/bosk/boson/codec/PrimitiveInjector.java | Updates primitive-number injector to Injector API. |
| boson/src/test/java/works/bosk/boson/codec/CodecHappyParseTest.java | Converts settings from ctor parameter to injected field + @BeforeEach init. |
| boson/src/test/java/works/bosk/boson/codec/BasicCodecTest.java | Converts settings from ctor parameter to injected field + @BeforeEach init. |
| boson/build.gradle | Adds bosk-junit as a test dependency for boson tests. |
| bosk-testing/src/test/java/works/bosk/testing/drivers/ForgottenFlushTest.java | Updates initial-state method references to instance form. |
| bosk-testing/src/main/java/works/bosk/testing/drivers/SharedDriverConformanceTest.java | Updates initial-state method references to instance form. |
| bosk-testing/src/main/java/works/bosk/testing/drivers/DriverConformanceTest.java | Migrates internal injectors to Injector API and AnnotatedElement checks. |
| bosk-testing/src/main/java/works/bosk/testing/drivers/AbstractDriverTest.java | Makes initialState an instance method; adjusts logging to keep TestInfo in a field. |
| bosk-sql/src/test/java/works/bosk/drivers/sql/SqlDriverDurabilityTest.java | Replaces @ParameterizedClass with field injection for database selection. |
| bosk-sql/src/test/java/works/bosk/drivers/sql/DatabaseInjector.java | Adds database injector for SQL driver tests. |
| bosk-mongo/src/test/java/works/bosk/drivers/mongo/internal/To.java | Adds field marker annotation to disambiguate injected configs. |
| bosk-mongo/src/test/java/works/bosk/drivers/mongo/internal/SchemaEvolutionTest.java | Replaces class parameterization with field injection + marker annotations for cartesian config pairs. |
| bosk-mongo/src/test/java/works/bosk/drivers/mongo/internal/MongoDriverHanoiTest.java | Replaces @ParameterizedClass with field injection and @BeforeEach setup. |
| bosk-mongo/src/test/java/works/bosk/drivers/mongo/internal/From.java | Adds field marker annotation to disambiguate injected configs. |
| bosk-mongo/src/test/java/works/bosk/drivers/mongo/internal/DottedFieldNameTest.java | Extends AbstractDriverTest and migrates initial-state method reference usage. |
| bosk-mongo/build.gradle | Adds bosk-junit as a test dependency for mongo tests. |
| bosk-junit/src/test/java/works/bosk/junit/ParameterizedClassTest.java | Removes old tests tied to @ParameterizedClass/ParameterInjector. |
| bosk-junit/src/test/java/works/bosk/junit/ParameterInjectionContextProviderTest.java | Removes old tests for the prior parameter injection implementation. |
| bosk-junit/src/test/java/works/bosk/junit/CorrelatedParameterTest.java | Removes manual/disabled correlated injection test for old API. |
| bosk-junit/src/test/java/works/bosk/junit/InjectFromHappyPathTests.java | Adds new happy-path tests for field and method injection behavior under JUnit. |
| bosk-junit/src/main/java/works/bosk/junit/ParameterInjectionSupport.java | Introduces shared branch/cartesian-product/injector instantiation logic used by both injection modes. |
| bosk-junit/src/main/java/works/bosk/junit/ParameterInjectionContextProvider.java | Refactors to use shared support and incorporate class-level branch state. |
| bosk-junit/src/main/java/works/bosk/junit/Injector.java | Renames/expands injector interface to support both fields and parameters. |
| bosk-junit/src/main/java/works/bosk/junit/InjectedTest.java | Updates documentation to reflect Injector + field injection options. |
| bosk-junit/src/main/java/works/bosk/junit/Injected.java | Adds new annotation for field injection. |
| bosk-junit/src/main/java/works/bosk/junit/InjectFrom.java | Updates annotation to reference Injector and include fields in scope. |
| bosk-junit/src/main/java/works/bosk/junit/InjectFields.java | Adds new class-level annotation enabling field injection via @ClassTemplate. |
| bosk-junit/src/main/java/works/bosk/junit/FieldInjectionContextProvider.java | Adds new class template provider that instantiates test classes and populates injected fields. |
| bosk-junit/src/main/java/module-info.java | Adds SLF4J module requirement for new logging. |
| bosk-junit/USERS.md | Adds a user guide for injection features and usage patterns. |
| bosk-core/src/test/java/works/bosk/drivers/ReplicaSetTest.java | Updates initial-state method references to instance form. |
| bosk-core/src/test/java/works/bosk/drivers/ReplicaSetConformanceTest.java | Updates initial-state method references to instance form. |
| bosk-core/src/test/java/works/bosk/BoskContextTest.java | Updates initial-state method references to instance form. |
| bosk-core/src/test/java/works/bosk/IdentifierTest.java | Migrates injectors to Injector API and AnnotatedElement checks. |
| CLAUDE.md | Adds commit hygiene guidelines to contributor guidance. |
Comments suppressed due to low confidence (1)
bosk-junit/src/main/java/works/bosk/junit/Injector.java:44
Injector.ofTypewill never match anything: it compareselement(aParameter/Field) totype(aClass). This makes the helper unusable and silently breaks injection when callers useInjector.ofType. CompareelementType(or((Parameter)element).getType()) totypeinstead.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bosk-mongo/src/test/java/works/bosk/drivers/mongo/internal/DottedFieldNameTest.java
Show resolved
Hide resolved
bosk-junit/src/main/java/works/bosk/junit/ParameterInjectionSupport.java
Show resolved
Hide resolved
bosk-junit/src/main/java/works/bosk/junit/FieldInjectionContextProvider.java
Show resolved
Hide resolved
bosk-junit/src/main/java/works/bosk/junit/FieldInjectionContextProvider.java
Outdated
Show resolved
Hide resolved
bosk-junit/src/main/java/works/bosk/junit/ParameterInjectionSupport.java
Show resolved
Hide resolved
bosk-junit/src/test/java/works/bosk/junit/InjectFromHappyPathTests.java
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JUnit's parameterization is not composable. Any given class has to decide, once and for all, what all its argument sources are, and that means (for example) superclasses can't introduce their own parameters and argument sources.
This PR extends our existing injection extension so it can inject into fields annotated with
@Injected.