-
Notifications
You must be signed in to change notification settings - Fork 0
ANDROID-17148 -- Fix double extension when generating files in Snapshot Testing library #16
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
Conversation
…n log file is creating
|
After moving Loggerazzi fixes to this library, we introduced some bugs. I've done two changes:
|
| val goldenFile = directories.context.assets.open("${directories.goldenFilesDir}/${testName}.txt") | ||
| val goldenStringLogs = String(goldenFile.readBytes()).takeIf { it.isNotEmpty() }?.split("\n") ?: emptyList() | ||
| val comparison = compare(goldenStringLogs) | ||
| writeRecordedLogsToFile(fileName, comparison.recordedLogs) |
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.
Should it be reviewed screenshot tests too? they have similar logic
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've double-checked it, the ScreenshotsRule is saving the screenshots before failing the test so there isn't any problem in that case https://github.com/Telefonica/android-snaptesting/blob/main/android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt#L99
juangardi21
left a comment
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 catch
pmartinbTEF
left a comment
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.
Good job!
🎟️ Jira ticket
ANDROID-17148
🥅 What's the goal?
Fix an issue in the library that generates recorded log files with a duplicated .txt extension (e.g.
TestClass_testMethod.txt.txt).This duplicated extension breaks the comparison against the corresponding golden files, which are correctly defined with a single .txt extension.
🚧 How do we do it?
To fix this behaviour, it was updated the file-naming logic inside
LogsRuleso that the temporary log file generated during test execution no longer includes the .txt suffix.This allows the Gradle plugin (
AndroidSnaptestingPlugin) to correctly rename the latest generated recording to .txt without producing a double extension.Implementation steps:
.txtsuffix from the temporary filename created inLogsRule.${testName}.txt.${System.nanoTime()}${testName}.${System.nanoTime()}<testName>.txt), ensuring full backwards compatibility.<testName>.txtwithout duplication..txt.txt.📘 Documentation changes?
🧪 How can I test this?
LogsRule, for example:./gradlew :app:connectedDebugAndroidTestapp/build/reports/androidTests/connected/debug/androidSnapTesting/recorded/<TestClass>_<method>.txt