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

[IDE Plugin] More flexible screenshots paths detection #467

Open
Pschsch opened this issue Aug 15, 2024 · 2 comments
Open

[IDE Plugin] More flexible screenshots paths detection #467

Pschsch opened this issue Aug 15, 2024 · 2 comments

Comments

@Pschsch
Copy link

Pschsch commented Aug 15, 2024

@takahirom Thank you so much for library and all the collaborators.

Problem: by default, IDE plugin looks for screenshot names by next pattern:
{selected screenshots folder in settings}/{Test class name}.{Test name}.png
If I change this pattern, IDE Plugin breaks, it could not resolve paths to generated screenshots.
Consider the next case:
I have test class:

// Robolectric setup
class TestClass {
    @Test fun myTest() { /* some screenshot logic */ } 
}

And I want to store screenshot of this test in path:
src/test/screenshots/com.test.TestClass/myTest.png

IDE plugin would not detect location of this screenshot and show empty window when focused on it.

Possible solution as I see it:
Generate some mapping file for IDE plugin, where key is full-qualified test name and value is path to screenshot.
Mapping file will be edited on each captureRoboImage()
Possible example of mapping in this case in JSON format:

[
  {
    "testName": "com.test.TestClass.myTest",
    "screenshotPath": "src/test/screenshots/com.test.TestClass/myTest.png"
  }
]

We could store it in some location of build directory, for example, build/intermediates/roborazzi

And look for screenshot path by testName key.

It's will be also nice to have ability to disable mapping file generation, for example, via gradle plugin extension property to reduce possible performance affects on CI.

@takahirom What do you think about this solution?

@takahirom
Copy link
Owner

takahirom commented Aug 15, 2024

Thank you for using Roborazzi!
Well, we actually have that kind of JSON file in the test-results directory. So I think we have the information we need. The reason why we don't do it is that it could be a bit challenging to implement. Another approach could be to improve the image search algorithm using the pathname.

  "results": [
    {
      "golden_file_path": "xxx/git/conference-app-2024/feature/profilecard/build/outputs/roborazzi/ProfileCardScreenTest[ProfileCardScreen - when profile card is not found - input nickname - input occupation - click create button - click edit button - it should show edit screen].png",
      "timestamp": 839363151954000,
      "context_data": {
        "roborazzi_description_class": "io.github.droidkaigi.confsched.profilecard.ProfileCardScreenTest"
      },
      "type": "recorded"
    },
    {
      "golden_file_path": "xxx/git/conference-app-2024/feature/profilecard/build/outputs/roborazzi/ProfileCardScreenTest[ProfileCardScreen - when profile card is not found - input nickname - input occupation - click create button - click edit button - it should show edit screen].png",
      "timestamp": 839363091096916,
      "context_data": {
        "roborazzi_description_class": "io.github.droidkaigi.confsched.profilecard.ProfileCardScreenTest"
      },
      "type": "recorded"
    }
  ]

@takahirom
Copy link
Owner

I've created a issue for this.
#485

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

No branches or pull requests

2 participants