Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes 3463 replace assert with assert that #5107

Closed

Conversation

u7281898
Copy link

Description (required)

Fixes #3463

What changes did you make and why?

I replaced all instances of assert() with assertThat() where appropriate.
assertThat() error messages are easier to understand and the assertThat method has a wider range of abilities to determine if the output of a function is appropriate. For example assertThat will not complete compiling instead of failing if the expected input is an integer instead of a string.

Tests performed (required)

Tested AccountUtilUnitTest with Pixel 2 API 30

@u7281898 u7281898 changed the title 3463 replace assert with assert that FIxes 3463 replace assert with assert that Oct 30, 2022
@u7281898 u7281898 changed the title FIxes 3463 replace assert with assert that Fixes 3463 replace assert with assert that Oct 30, 2022
Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good generally, just a few minor things to improve.

@@ -47,6 +47,7 @@ dependencies {
implementation 'com.karumi:dexter:5.0.0'
implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
// implementation 'com.google.firebase:firebase-firestore:24.1.2'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?

//import static org.junit.Assert.assertThat;
//import static org.hamcrest.Matchers.is;
//import static org.hamcrest.Matchers.not;
//import static org.hamcrest.Matchers.nullValue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?

@@ -991,6 +995,7 @@ public void onActivityResult(final int requestCode, final int resultCode,

if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {

// assertThat(data, not(nullValue()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?


defaultConfig {
minSdkVersion 19
targetSdkVersion 28
targetSdkVersion 30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed?

@@ -3,13 +3,16 @@ package fr.free.nrw.commons.auth
import fr.free.nrw.commons.FakeContextWrapper
import fr.free.nrw.commons.FakeContextWrapperWithException
import fr.free.nrw.commons.TestCommonsApplication
import org.junit.Assert
import org.junit.Assert.*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind importing only the needed classes, explicitly?

import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
import org.hamcrest.CoreMatchers.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind importing only the needed classes, explicitly?

@domdomegg
Copy link
Member

Closing this as now stale

@domdomegg domdomegg closed this Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove usages of assert
3 participants