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

Support alternate test suites #1520

Open
yogurtearl opened this issue Aug 2, 2024 · 4 comments
Open

Support alternate test suites #1520

yogurtearl opened this issue Aug 2, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@yogurtearl
Copy link

Gradle supports multiple test suites: https://docs.gradle.org/current/userguide/jvm_test_suite_plugin.html

AGP doesn't support this yet:
https://issuetracker.google.com/issues/307694643

If/when AGP does support a test suite concept, paparazzi would need to allow for configuring with test suites it will run in.

As of version 1.3.4, it looks like it only supports a default test suite named "test".

configurations.getByName("testImplementation").dependencies.add(dependency)

project.tasks.withType(Test::class.java).named { it == "test$testVariantSlug" }

@yogurtearl yogurtearl added the enhancement New feature or request label Aug 2, 2024
@jrodbx
Copy link
Collaborator

jrodbx commented Aug 2, 2024

Gradle supports multiple test suites: https://docs.gradle.org/current/userguide/jvm_test_suite_plugin.html

Gradle per se doesn't; that link points to documentation for the JVM test suite plugin. Even Xav mentions that here: https://issuetracker.google.com/issues/307694643#comment7

Does Gradle intend to provide core platform for this?

Taking a step back, what's the value proposition of supporting this? It's not clear to me why the "very useful" part of the feature request in AGP would be: https://issuetracker.google.com/issues/307694643#comment1.

If it's because of AGP/Robolectric conflicting with each other re: bytecode manipulation, then I'd encourage fixing that instead. If it's to run a subset of tests, using --tests with a regex or test annotation markers would be preferred here.

Mind elaborating more on the use cases?

@jrodbx jrodbx added the waiting on user Waiting on information from OP label Aug 2, 2024
@TWiStErRob
Copy link
Contributor

The point of test suites is to separate the suites. In Android this comes with different tech, in JVM too, but only sometimes.

Screenshot tests are a very specific type of tests, just like unit tests, instrumentation tests, etc. I could imagine an integration tests as a suite as well. Each of these groups of tests would have different dependencies, and different approaches, which could go as far as one running TestNG and another JUnit.

Yes, it is possible (potentially with hacks and workarounds) to have all of these in one source set, but why would that be the norm if we can do better? Simply splitting up tests into source sets solves a ton of problems. You can have different resources, annotation processors, even languages!

Also how much more ergonomic is gradlew :foo:testDebugPaparazziTest than gradlew :foo:testDebugUnitTest --test "com.example.**.*ScreenshotTest" -DscreenshotTest=on. Much less implied knowledge, improved compilation, dependency management, separation of concerns etc.

@yogurtearl
Copy link
Author

yogurtearl commented Aug 2, 2024

Does Gradle intend to provide core platform for this?

The jvm-test-suite plugin is included in gradle, similar to how the java-library or java-test-fixtures plugins are included with gradle, but yeah it is implemented as a plugin.

AGP doesn't currently support the jvm-test-suite plugin or concepts, but they could add support in a similar way to how they added support for the java-test-fixtures concepts.

Mind elaborating more on the use cases?

Having layoutlib on the classpath provides different implementations of android.* class compared to what you normally get from android.jar. (We have tests that fail just by the presence of layoutlib on the class path before android.jar)

We need to support tests that work in a "plain old" android /test setup without layoutlib (or roboletric) on the classpath.

With a separate test suite, tests that require the android.jar versions of android.* stubs would work if paparazzi is kept to a separate test suite.

I opened this issue more as a placeholder for if/when AGP ever decides to support the jvm-test-suite plugin or concepts.

Our current workaround will be to have plain old unit tests in :feature:foo:ui (in /test) and put Paparazzi tests in :feature:foo:screenshots (in /test)
and in feature/foo/screenshots/build.gradle.kts we will have testImplementation(projects.feature.foo.ui)

@yogurtearl
Copy link
Author

can we remove the waiting on user tag on this one?

@jrodbx jrodbx removed the waiting on user Waiting on information from OP label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants