Skip to content

Commit 31df94e

Browse files
authored
Merge pull request #211 from jselbo/mockito
Implement singleton mocks for dexmaker-mockito-inline
2 parents ff8bb50 + 3432470 commit 31df94e

21 files changed

Lines changed: 284 additions & 25 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
mavenCentral()
55
}
66
dependencies {
7-
classpath 'com.android.tools.build:gradle:8.10.0'
7+
classpath 'com.android.tools.build:gradle:8.13.2'
88
}
99
}
1010

dexmaker-mockito-inline-extended-tests/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ dependencies {
3030
androidTestImplementation 'androidx.test:runner:1.4.0'
3131
androidTestImplementation 'androidx.test:rules:1.4.0'
3232

33-
androidTestImplementation 'org.mockito:mockito-core:2.28.2', { exclude group: 'net.bytebuddy' }
33+
androidTestImplementation libs.mockito.core, { exclude group: 'net.bytebuddy' }
3434
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<application>
5+
<activity android:name="com.android.dx.mockito.inline.extended.tests.EmptyActivity"
6+
android:exported="false" />
7+
</application>
8+
</manifest>

dexmaker-mockito-inline-extended-tests/src/androidTest/java/com/android/dx/mockito/inline/extended/tests/MockStatic.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
2626
import static com.android.dx.mockito.inline.extended.ExtendedMockito.reset;
2727
import static com.android.dx.mockito.inline.extended.ExtendedMockito.staticMockMarker;
28-
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verifyZeroInteractions;
28+
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verifyNoInteractions;
2929
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;
3030

3131
import static org.junit.Assert.assertEquals;
@@ -401,7 +401,7 @@ public void clearInvocationsRemovedInvocations() throws Exception {
401401
try {
402402
SuperClass.returnB();
403403
clearInvocations(staticMockMarker(SuperClass.class));
404-
verifyZeroInteractions(staticMockMarker(SuperClass.class));
404+
verifyNoInteractions(staticMockMarker(SuperClass.class));
405405
} finally {
406406
session.finishMocking();
407407
}

dexmaker-mockito-inline-extended-tests/src/androidTest/java/com/android/dx/mockito/inline/extended/tests/StaticMockitoSessionVsMockitoJUnitRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.junit.runner.RunWith;
2121
import org.mockito.junit.MockitoJUnitRunner;
2222

23-
@RunWith(MockitoJUnitRunner.class)
23+
@RunWith(MockitoJUnitRunner.Silent.class)
2424
public class StaticMockitoSessionVsMockitoJUnitRunner {
2525
@Test
2626
public void simpleStubbing() throws Exception {

dexmaker-mockito-inline-extended-tests/src/androidTest/java/com/android/dx/mockito/inline/extended/tests/VerifyStatic.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import static com.android.dx.mockito.inline.extended.ExtendedMockito.staticMockMarker;
3131
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
3232
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verifyNoMoreInteractions;
33-
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verifyZeroInteractions;
33+
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verifyNoInteractions;
3434
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;
3535
import static org.junit.Assert.assertEquals;
3636
import static org.junit.Assert.assertNull;
@@ -180,7 +180,7 @@ public void zeroInvocationsThrowsIfThereWasAnInvocation() throws Exception {
180180
MockitoSession session = mockitoSession().mockStatic(EchoClass.class).startMocking();
181181
try {
182182
EchoClass.echo("marco!");
183-
verifyZeroInteractions(staticMockMarker(EchoClass.class));
183+
verifyNoInteractions(staticMockMarker(EchoClass.class));
184184
fail();
185185
} finally {
186186
session.finishMocking();

dexmaker-mockito-inline-extended-tests/src/main/AndroidManifest.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
xmlns:tools="http://schemas.android.com/tools">
44

55
<application android:debuggable="true"
6-
tools:ignore="HardcodedDebugMode">
7-
<activity android:name="com.android.dx.mockito.inline.extended.tests.EmptyActivity" />
8-
</application>
6+
tools:ignore="HardcodedDebugMode" />
97
</manifest>

dexmaker-mockito-inline-extended/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ dependencies {
4646

4747
implementation project(':dexmaker-mockito-inline')
4848

49-
api 'org.mockito:mockito-core:2.28.2', { exclude group: 'net.bytebuddy' }
49+
api libs.mockito.core, { exclude group: 'net.bytebuddy' }
5050
}

dexmaker-mockito-inline-extended/src/main/java/com/android/dx/mockito/inline/extended/StaticInOrder.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.android.dx.mockito.inline.extended;
1818

1919
import org.mockito.InOrder;
20+
import org.mockito.MockedStatic;
2021
import org.mockito.Mockito;
2122
import org.mockito.verification.VerificationMode;
2223

@@ -141,6 +142,12 @@ public void verify(MockedMethod method, VerificationMode mode) {
141142
verify((MockedVoidMethod) method::get, mode);
142143
}
143144

145+
@Override
146+
public void verify(MockedStatic<?> mockedStatic, MockedStatic.Verification verification,
147+
VerificationMode mode) {
148+
instanceInOrder.verify(mockedStatic, verification, mode);
149+
}
150+
144151
@Override
145152
public void verifyNoMoreInteractions() {
146153
instanceInOrder.verifyNoMoreInteractions();

dexmaker-mockito-inline-tests/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ dependencies {
3030

3131
androidTestImplementation 'junit:junit:4.13.2'
3232
androidTestImplementation 'androidx.test:runner:1.4.0'
33-
androidTestImplementation 'org.mockito:mockito-core:2.28.2', { exclude group: 'net.bytebuddy' }
33+
androidTestImplementation libs.mockito.core, { exclude group: 'net.bytebuddy' }
3434
}

0 commit comments

Comments
 (0)