-
Notifications
You must be signed in to change notification settings - Fork 536
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
Fix Part of #4236 : Add tests for AsyncResultSubject #5670
base: develop
Are you sure you want to change the base?
Fix Part of #4236 : Add tests for AsyncResultSubject #5670
Conversation
Hey @adhiamboperes PTAL, and suggest me if there are any changes to make. |
Hey @adhiamboperes, PTAL !! |
Coverage ReportResultsNumber of files assessed: 3 Passing coverageFiles with passing code coverage
Exempted coverageFiles exempted from coverage
|
Coverage ReportResultsNumber of files assessed: 1 Exempted coverageFiles exempted from coverage
|
Hey @adhiamboperes , could you please take a look ? Thanks !! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @TanishMoral11!
I noticed that you have not fully tested the class. Additionally, please rename the tests following the pattern that I have suggested.
@@ -33,3 +33,21 @@ oppia_android_test( | |||
"//utility/src/main/java/org/oppia/android/util/networking:debug_module", | |||
], | |||
) | |||
|
|||
# Adding test for AsyncResultSubject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this file from test_file_exemptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done .
import org.oppia.android.util.data.AsyncResult | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RunWith(RobolectricTestRunner::class) | |
@RunWith(JUnit4::class) |
class AsyncResultSubjectTest { | ||
|
||
@Test | ||
fun testAsyncResultPending_isPending() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun testAsyncResultPending_isPending() { | |
fun testAsyncResultSubject_pendingResult_checkIsPending() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
@Test | ||
fun testAsyncResultPending_isNotSuccess() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun testAsyncResultPending_isNotSuccess() { | |
fun testAsyncResultSubject_pendingResult_checkIsNotSuccess() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are also missing a corresponding "isNotFailure()" test.
@Test | ||
fun testAsyncResultSuccess_hasSuccessValueWhere_matchesExpected() { | ||
val successResult: AsyncResult<String> = AsyncResult.Success("Success value") | ||
|
||
AsyncResultSubject.assertThat(successResult).hasSuccessValueWhere { | ||
// Here we are verifying that the value is "Success value" | ||
assertThat(this).isEqualTo("Success value") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion to reduce ambiguity.
@Test | |
fun testAsyncResultSuccess_hasSuccessValueWhere_matchesExpected() { | |
val successResult: AsyncResult<String> = AsyncResult.Success("Success value") | |
AsyncResultSubject.assertThat(successResult).hasSuccessValueWhere { | |
// Here we are verifying that the value is "Success value" | |
assertThat(this).isEqualTo("Success value") | |
} | |
} | |
@Test | |
fun testAsyncResultSuccess_hasSuccessValueWhere_matchesExpected() { | |
val successResult: AsyncResult<String> = AsyncResult.Success("Some string") | |
AsyncResultSubject.assertThat(successResult).hasSuccessValueWhere { result -> | |
assertThat(result).isEqualTo("Some string") | |
} | |
} |
Coverage ReportResultsCoverage Analysis: SKIP ⏭️ This PR did not introduce any changes to Kotlin source or test files.
|
Explanation
Fixes part of #4236: Adds tests to ensure correct handling of non-iterable async results.
This PR adds tests for the
AsyncResultSubject
class. It verifies that theAsyncResultSubject
handles non-iterable results correctly and ensures that the expected failures occur when the result is not iterable. The test specifically checks that the appropriate behavior is triggered when a non-iterable result is provided.Essential Checklist