File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
auth/src/test/java/com/firebase/ui/auth/testhelpers Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -76,17 +76,19 @@ public static void initialize() {
7676 }
7777
7878 private static void spyContextAndResources () {
79- // In Mockito 5.x, we need to avoid spying on objects that are already mocks/spies
79+ // In Mockito 5.x with inline mock maker, we can spy on final classes
80+ // Use doReturn().when() pattern to avoid calling real methods during stubbing
8081 if (!org .mockito .Mockito .mockingDetails (CONTEXT ).isSpy ()) {
8182 CONTEXT = spy (CONTEXT );
8283 }
8384 doReturn (CONTEXT ).when (CONTEXT ).getApplicationContext ();
8485
85- Resources resources = CONTEXT .getResources ();
86- if (!org .mockito .Mockito .mockingDetails (resources ).isSpy ()) {
87- resources = spy (resources );
86+ // Get and spy on Resources, ensuring the spy is properly returned
87+ Resources originalResources = CONTEXT .getResources ();
88+ if (!org .mockito .Mockito .mockingDetails (originalResources ).isSpy ()) {
89+ Resources spiedResources = spy (originalResources );
90+ doReturn (spiedResources ).when (CONTEXT ).getResources ();
8891 }
89- doReturn (resources ).when (CONTEXT ).getResources ();
9092 }
9193
9294 private static void initializeApp (Context context ) {
You can’t perform that action at this time.
0 commit comments