Standardize and expand unit tests#1034
Open
Avery-Dunn wants to merge 7 commits into
Open
Conversation
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.
This PR systematically expands unit test coverage across the core classes identified as having significant gaps in a JaCoCo coverage analysis report.
Several pre-existing bugs were discovered and documented during testing. The tests themselves are intentionally written to document current behavior (including bugs), not to mask or fix them, and these will be handled in a separate PR.
Test Results
Changes
This PR focuses on a few "groups" of classes, each of which has similar behavior and test scenarios, as well as some core classes where most successful token flows end (and thus provide a common area to verify behavior in earlier parts of test's flow)
Group 1: Application Classes (ApplicationBuilderTest.java — 53 new tests)
Tests for PublicClientApplication, ConfidentialClientApplication, ManagedIdentityApplication, and their builders.
Covers: authority types (AAD, B2C, ADFS, CIAM, OIDC), builder option propagation, null validation, broker integration, instance discovery settings.
Group 2: Parameters Classes (ParameterBuilderTest.java — 60 new tests, AuthorizationRequestUrlParametersTest.java — 6 new tests)
Tests for all 14 parameter builder classes (ClientCredentialParameters, SilentParameters, OnBehalfOfParameters, InteractiveRequestParameters, etc.).
Bugs discovered:
efreshToken (copy-paste bug)
Group 3: Supplier Classes (AppTokenProviderTest.java — 14 new tests)
Tests for AcquireTokenByAppProviderSupplier and the app token provider branch of AcquireTokenByClientCredentialSupplier.
Covers: valid/invalid provider results, parameter propagation, cache bypass behavior, refresh-in auto-calculation, exception wrapping.
Group 4: Request Classes (3 new tests in ApplicationBuilderTest.java)
Tests for InteractiveRequest.validateRedirectUrl() — the only directly testable validation logic in request classes. Other request classes are thin internal DTOs tested indirectly through flow tests.
Token Cache (CacheTest.java — 11 new tests)
Covers: serialization round-trips, account removal, cache merge, CacheAspect lifecycle callbacks, FOCI/family RT selection,
efreshOn propagation.
AuthenticationResult (AuthenticationResultTest.java — 35 new tests)
Bug discovered (HIGH severity):
ull when set via the builder, because field initializers execute before the constructor body in Java
Test Infrastructure & Maintainability Improvements
Shared Helpers (TestHelper.java)
Added centralized test infrastructure to reduce duplication across test files:
Code Quality Fixes in Existing Tests
eadResource() from AccountTest (delegated to TestHelper)