-
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
Fixes #4272: Added Tests for EventLogSubject. #5678
base: develop
Are you sure you want to change the base?
Fixes #4272: Added Tests for EventLogSubject. #5678
Conversation
Hi @adhiamboperes PTAL, as mentioned in the PR description these tests are not complete , once reviewed I would further add the remaining tests as |
Coverage ReportResultsNumber of files assessed: 1 Exempted coverageFiles exempted from coverage
|
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 @theayushyadav11!
My main suggestion is to change how the tests are named to reflect classUnderTest_condition1BeingTested_condition2ifApplicable_expectedOutcome()
Please rename these tests before adding more so that you can get a good grasp of the pattern.
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.
Please remove this file from test_file_exemptions.textproto
so code coverage analysis can run.
@@ -70,8 +70,6 @@ import org.oppia.android.app.model.UserTypeAnswer | |||
import org.oppia.android.app.model.WrittenTranslationLanguageSelection | |||
import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat | |||
|
|||
// TODO(#4272): Add tests for this 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.
Please do a global search and remove any other occurrances of this TODO(#4272)
.
@RunWith(JUnit4::class) | ||
class EventLogSubjectTest { | ||
@Test | ||
fun testHasTimeStamp_withTimeStamp_matchesTimeStamp() { |
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.
All the tests in this class needs to be renamed to follow our preferred format: https://github.com/oppia/oppia-android/wiki/Oppia-Android-Testing#guidelines-for-testing, e.g. testEventLogSubject_matchesCorrectTimestamp
testEventLogSubject_failsOnUnmatchingTimestamp
@Test(expected = AssertionError::class) | ||
fun testHasTimeStamp_withDifferentTimeStamp_fails() { | ||
val eventLog = EventLog.newBuilder() | ||
.setTimestamp(123456789) | ||
.build() | ||
|
||
EventLogSubject.assertThat(eventLog) | ||
.hasTimestampThat() | ||
.isEqualTo(987654321) | ||
} |
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.
We don't use this pattern when testing. Prefer something likee:
@Test(expected = AssertionError::class) | |
fun testHasTimeStamp_withDifferentTimeStamp_fails() { | |
val eventLog = EventLog.newBuilder() | |
.setTimestamp(123456789) | |
.build() | |
EventLogSubject.assertThat(eventLog) | |
.hasTimestampThat() | |
.isEqualTo(987654321) | |
} | |
@Test | |
fun testEventLogSubject_failsOnUnmatchingTimestamp() { | |
val eventLog = EventLog.newBuilder() | |
.setTimestamp(123456789) | |
.build() | |
assertThrows<AssertionError>() { | |
EventLogSubject.assertThat(eventLog) | |
.hasTimestampThat() | |
.isEqualTo(987654321) | |
} | |
} |
} | ||
|
||
@Test(expected = AssertionError::class) | ||
fun testIsEssentialPriority_withDifferentPriority_fails() { |
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 testIsEssentialPriority_withDifferentPriority_fails() { | |
fun testEventLogSubject_matchEssentialPriorityWithDifferentPriority_fails() { |
} | ||
|
||
@Test | ||
fun testHasNoProfileId_withNoProfileId() { |
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 testHasNoProfileId_withNoProfileId() { | |
fun testEventLogSubject_eventWithNoProfileId_returnsNoProfileId() { |
Ditto test below
"//:dagger", | ||
"//testing", |
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.
Are these two deps really required here?
Thanks @adhiamboperes for the review, I'll implement the changes as required. |
Coverage ReportResultsNumber of files assessed: 1 Failing coverage
|
Hi @adhiamboperes, PTAL! Let me know if I should continue writing tests for other methods or if you have any other suggestions. Thanks! |
Unassigning @theayushyadav11 since a re-review was requested. @theayushyadav11, please make sure you have addressed all review comments. Thanks! |
Fixes #4272:
This pull request introduces new tests for the
EventLogSubject
class in theOppia
Android project. The main changes include the addition of theEventLogSubjectTest
class and the corresponding build configuration updates.New Tests for
EventLogSubject
:testing/src/test/java/org/oppia/android/testing/logging/EventLogSubjectTest.kt
: Added a comprehensive set of tests for theEventLogSubject
class, covering various scenarios such as timestamp matching, priority checks, profile ID validation, and language selection verification.Build Configuration Updates:
testing/src/test/java/org/oppia/android/testing/logging/BUILD.bazel
: Added a new build target forEventLogSubjectTest
, including necessary dependencies for running the tests.Code Cleanup:
testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt
: Removed outdated TODO comments related to adding tests for theEventLogSubject
class.There are many tests which are remaining to be written, seeking a review for the current code so that new tests could be added.
Screenshot of the current passing tests:
Essential Checklist