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

148: Refactor output path into Destination #162

Merged
merged 6 commits into from
Sep 9, 2023
Merged

Conversation

DanielJette
Copy link
Contributor

@DanielJette DanielJette commented Jul 30, 2023

What does this change accomplish?

Prerequisite for #148

How have you achieved it?

This PR introduces two core changes:

  1. File manipulation is now abstracted through the new Destination interface. This allows Testify to implement various alternative file output locations. The existing data/data and sdcard output destinations have been ported to the new interface. This allows for future destinations to be easily supported in the future. This change is backwards compatible.
  2. The Testify Gradle Plugin can now write to AndroidManifest placeholder values in the target application. This means that custom attributes defined in build.gradle are now visible to the Library code. So, advanced configuration options can now be set in the build.gradle file and used by any Library code. In this PR, I have used this feature to pass the useSdCard configuration option to the Library and also to pass the current Gradle module name.

📔 In addition, a small refactoring to ErrorCause was made to support the two new exceptions added

Scope of Impact and Testing instructions

  • ScreenshotTest and Reporter now use the Destination interface. This should not affect users of Testify, but does impact developers and those who wish to subclass Testify classes.
  • The tests have been updated to reflect these changes.

Notice

Warning
This change must keep main in a shippable state; it may be shipped without further notice.

@DanielJette DanielJette force-pushed the 148-custom-output-path branch from b02dcaa to ff59f02 Compare September 5, 2023 00:45
@AndroidTestifyBot
Copy link
Contributor

AndroidTestifyBot commented Sep 5, 2023

✅ Success! - Legacy Sample screenshot test results

View build for commit 4b07565

@AndroidTestifyBot
Copy link
Contributor

AndroidTestifyBot commented Sep 5, 2023

✅ Success! - Flix Sample screenshot test results

View build for commit 4b07565

@DanielJette DanielJette marked this pull request as ready for review September 5, 2023 01:32
@DanielJette DanielJette requested review from olegosipenko, AndroidTestifyBot and a team and removed request for olegosipenko September 5, 2023 01:32
useSdCard = useSdCard(InstrumentationRegistry.getArguments()),
path = getOutputDirectoryPath(this).absolutePath
)
private fun Destination.assureScreenshotDirectory(context: Context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this method be part of Destination class? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a convenience wrapper around Destination.assureDestination() which checks the return value of assureDestination() and throws an exception if it's false.

@ndtp ndtp deleted a comment from AndroidTestifyBot Sep 5, 2023
@DanielJette DanielJette merged commit f2c50d1 into main Sep 9, 2023
4 checks passed
@DanielJette DanielJette deleted the 148-custom-output-path branch September 9, 2023 16:52
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.

3 participants