Skip to content

Commit

Permalink
Fix flaky ResultTest and build config warnings (#785)
Browse files Browse the repository at this point in the history
I haven't created a ticket for these changes.

## Proposed Changes

- Fix `ResultTest.getLastResult` by ensuring that the first result
really has a start_time before the second result
  - Fix `BuildConfig` warning by changing to the new configuration
- Remove the `mockito-inline` dependency, since it's no longer needed
for Mockito 5

### Context

- This PR started as an attempt to fix
ooni/probe#2777 but I wasn't able to do it yet
  • Loading branch information
sdsantos authored Jul 17, 2024
1 parent 0ba230e commit 1b8924c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ android {
}
buildFeatures {
viewBinding = true
buildConfig = true
}
namespace 'org.openobservatory.ooniprobe'
}
Expand Down Expand Up @@ -176,7 +177,6 @@ dependencies {
testImplementation libs.androidx.runner
testImplementation libs.androidx.rules
testImplementation libs.mockito.core
testImplementation libs.mockito.inline
testImplementation libs.robolectric
testImplementation libs.faker
testImplementation libs.ooni.oonimkall
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public void onCreate() {

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
@SuppressWarnings("unchecked")
ArrayList<AbstractSuite> testSuites = (ArrayList<AbstractSuite>) intent.getSerializableExtra("testSuites");
if (testSuites == null || testSuites.size() == 0)
if (testSuites == null || testSuites.isEmpty())
return START_STICKY_COMPATIBILITY;
boolean store_db = intent.getBooleanExtra("storeDB", true);
boolean unattended = intent.getBooleanExtra("unattended", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public void readableFileSize() {
@Test
public void getLastResult() {
Result first = new Result("");
first.start_time = new Date(System.currentTimeMillis() - 1000);
first.save();
Result second = new Result("");
second.save();
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.defaults.buildfeatures.buildconfig=true
android.enableJetifier=true
android.nonFinalResIds=false
android.nonTransitiveRClass=false
Expand Down
6 changes: 2 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ androidGradlePlugin = "8.5.1"
barista = "3.9.0"
countlySdk = "24.7.0"
faker = "2.0.4"
mockitoCore = "5.12.0"
mockitoInline = "5.2.0"
mockito = "5.12.0"
robolectric = "4.13"
fastlaneScreengrab = "2.1.1"
sentryAndroid = "7.11.0"
Expand Down Expand Up @@ -64,8 +63,7 @@ xanscale-localhost-toolkit = { module = "com.github.xanscale.LocalhostToolkit:ap
commons-io = { module = "commons-io:commons-io", version.ref = "commonsIo" }
kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }

mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockitoCore" }
mockito-inline = { module = "org.mockito:mockito-inline", version.ref = "mockitoInline" }
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }

lottie = { module = "com.airbnb.android:lottie", version.ref = "lottie" }
markwon-core = { module = "io.noties.markwon:core", version.ref = "markwon" }
Expand Down

0 comments on commit 1b8924c

Please sign in to comment.