-
Notifications
You must be signed in to change notification settings - Fork 1
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 for running tests #65
Conversation
Quality Gate passedIssues Measures |
β¦x-tests-dependencies-04-package-name
Tests can be run now and all are passing, some work still needs to be done in |
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.
Nice progress, I will do more detailed review once this PR is out of draft.
But once again kudos π
|
||
<provider | ||
android:name="androidx.startup.InitializationProvider" | ||
android:authorities="${applicationId}.androidx-startup" | ||
android:exported="false" | ||
tools:node="merge"> | ||
|
||
<meta-data | ||
android:name="androidx.work.WorkManagerInitializer" | ||
android:value="androidx.startup" | ||
tools:node="remove" /> | ||
</provider> |
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.
Why is this needed?
We removed need for this in last release
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.
I can't remember if there were any conflicts, but it is possible it is from that. I will re-check this.
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.
Okay, I see now. This is from initial commit to this branch by Neven when we were figuring out what is wrong with the tests. I will check if this can be removed.
WorkManager.initialize( | ||
context, | ||
Configuration.Builder().build() | ||
) |
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.
Same here
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 is only for Tests. WorkManager is missing and SentinelTests
couldn't be run.
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.
By removing meta-data for WorkManager this can also be removed.
Manifest.permission.POST_NOTIFICATIONS to false, | ||
Manifest.permission.POST_NOTIFICATIONS to false, |
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.
POST_NOTIFICATIONS twice
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.
Still twice...
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.
Removed, finally π
Fixed |
private fun checkDeviceSpecificFields(html: String): String { | ||
val fields = listOf( | ||
"screen_width", | ||
"screen_height", | ||
"screen_size", | ||
"screen_density", | ||
"font_scale" | ||
) | ||
|
||
val fieldPatterns = fields.map { field -> | ||
field to Regex("""<div>$field:\s*[^<]*</div>""") | ||
} | ||
|
||
var updatedHtml = html | ||
|
||
fieldPatterns.forEach { (field, pattern) -> | ||
val matchResult = pattern.find(updatedHtml) | ||
if (matchResult == null) { | ||
throw AssertionError("Field $field is missing in the device object") | ||
} else { | ||
updatedHtml = updatedHtml.replace(matchResult.value, """<div>$field: </div>""") | ||
} | ||
} | ||
|
||
return updatedHtml | ||
} | ||
|
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.
When it comes to StringBuilder
tests I didn't find an elegant way to mock these fields like it is the case with ReflectionHelpers
. So I went with this approach because I think it is only important to assert that field is there.
When I get more familiar with Roboelectric, I will return to this, unless you have suggestions.
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.
Kudos for taking the initiative and finally patching up tests π
I also don't have too much exp with π€ Robolectric and I see we quite often have patterns like checkDeviceSpecificFields
in tests. I assume we could probably improve that. But first and foremost everything is running as expected!
P.S.
Maybe you could share you gained knowledge on internal edu or team events π€
P.S. Part II
Take a look at Notification permission comment
Manifest.permission.POST_NOTIFICATIONS to false, | ||
Manifest.permission.POST_NOTIFICATIONS to false, |
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.
Still twice...
@@ -10,7 +10,7 @@ | |||
<application> | |||
|
|||
<activity | |||
android:name=".ui.main.SentinelActivity" | |||
android:name="com.infinum.sentinel.ui.main.SentinelActivity" |
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.
π
Quality Gate passedIssues Measures |
π· Screenshots
π Context
Tests can finally be run. Some of them are failing but that is a problem for another day.
π Changes
π Related PR
π« Breaking
π οΈ How to test
β±οΈ Next steps