pedrovgs / Shot

Screenshot testing library for Android
Apache License 2.0
1.18k stars 115 forks source link

Screenshots get deleted after being recorded. #323

Open cj1098 opened 1 year ago

cj1098 commented 1 year ago

Expected behaviour

I expect after running ./gradlew executeScreenshotTests -Precord that the tests get saved and stay in the directory they're saved in.

Actual behaviour

The entire directory gets deleted, and a new empty directory gets created in projects' build/reports/shot/debug/record/images/recorded. It has screenshots-default and screenshots-compose-default, but both are empty. It also has an index.html and that says 0 screenshot tests were run.

Steps to reproduce

run /gradlew executeScreenshotTests -Precord

Version of the library

I'm using Shot 5.14.1

My setup is as follows: I tried to follow the instruments as closely as possible. I have an AndroidManifest test file that declares sharedUserId, and I have declared that same id in app/AndroidManifest. in my project build.gradle I have declared in my dependencies classpath 'com.karumi:shot:5.14.1' My test runner is testInstrumentationRunner "com.karumi.shot.ShotTestRunner"

I've applied everything in the get started section possible (I think)

What I get is

Task :app:debugExecuteScreenshotTests 💾 Saving screenshots. 🤔 We couldn't find any screenshot. Did you configure Shot properly and added your tests to your project? https://github.com/pedrovgs/Shot/#getting-started

The odd thing is, after it deletes the directories then I get this error ☝️ , but if I add them back in manually and then run /gradlew executeScreenshotTests -Precord then it returns everything was successful, except it deletes everything... lol I see the files be generated then immediately deleted.

Task :app:debugExecuteScreenshotTests 💾 Saving screenshots. 😃 Screenshots recorded and saved at: /Users/chrisjohnson/StudioProjects/project/app/screenshots/debug/ 🤓 You can review the execution report here: /Users/chrisjohnson/StudioProjects/project/app/build/reports/shot/debug/index.html

My test is basic, with some infrastructure around compose.

class MessagesScreenTest : BaseComposeScreenTest<MessagesUiState, MessagesViewModel, UiEvent.Default>(
    MessagesUiState()
), ScreenshotTest {

    @Test
    fun testMessagesScreenShot() {
        setContent { viewModel ->
            MessagesScreen(viewModel = viewModel)
            updateUiState {
                it.copy(toolbarTitle = "test")
            }
        }
        compareScreenshot(composeTestRule)
    }
}