-
Notifications
You must be signed in to change notification settings - Fork 35
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
[Feature Request] Bazel Support #63
Comments
Apart from telling Roborazzi where to write the snapshots to and where to look for the previous ones, this pretty much works out of the box with Bazel: android_local_test(
name = "test",
jvm_flags = [
# Pass the Roborazzi flags that you need
"-Droborazzi.test.record=true",
# Pass in the runfiles path to the baselines
"-Dsnapshot.baseline='$(rlocationpath baseline.zip)'",
],
data = [
# Feed the baselines back in
"baseline.zip",
],
) @RunWith(AndroidJUnit4::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
class ExampleSnapshotTest {
private val workingDirectory = File(System.getenv("TEST_UNDECLARED_OUTPUTS_DIR")!!)
@get:Rule
val testRule = createSnapshotTestRule()
@get:Rule
val snapshotRule = SnapshotRule(testRule = testRule, outputDirectoryPath = workingDirectory.path) And you can place the snapshots back by doing: // Can be wrapped up into a custom JunitRule
val runfiles = Runfiles.preload()
val baselinesZipArchive = File(runfiles.unmapped().rlocation(System.getProperty("snapshot.baseline")!!))
unzip(baselinesZipArchive, workingDirectory) |
Excellent. Thanks for the insight @Bencodes . It sounds like there isn't anything more to want then. I'll close this for now and reopen if something comes up. |
If there is interest in supporting an open source Bazel specific wrapper around |
Thank you @bohregard and @Bencodes for discussing Bazel support for Roborazzi. I appreciate your insights and sample code. I'm considering creating a Feel free to reach out with any questions or concerns about Bazel integration. I'll monitor the issue tracker and provide support for any Bazel-related issues. Thanks for your input, and I look forward to improving Roborazzi for the Bazel community. |
Hey everyone, I've synced with @takahirom and I'll be happy to contribute the |
@sanchezz93, great to have you on board! Thanks for joining us on the roborazzi-bazel module. Looking forward to it! |
@Bencodes is it okay to support Roborazzi in robolectric-bazel? Ideally, Roborazzi might need to create a custom wrapper for itself but depends on robolectric-bazel? Or do you want to support common |
The company that I work for is using Bazel as the build tool for our application and we are considering using Roborazzi for snapshot testing in the future. We've done some internal testing and it looks like the tool doesn't need the Gradle plugin to successfully run since you can pass in the environment flag. For instance in Gradle we could do:
All tests that incorporate Roborazzi will then output the snapshots. (Obviously they will always do that but that's ok for us since that's our desired output).
Ideally we would build a custom rule on android_local_test (something like
snapshot_local_test
) where we pass in the custom environment variable for Roborazzi.The challenge is then Bazel outputs everything into a build output directory (https://bazel.build/remote/output-directories). Is it possible to bake support for moving the snapshot tests to the root src directory after a successful rule has executed?
The text was updated successfully, but these errors were encountered: