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

FileNotFoundException for metdata.xml file while running a particular case #55

Closed
arjungovindgv opened this issue Mar 21, 2019 · 13 comments

Comments

@arjungovindgv
Copy link

Expection Got :
java.io.FileNotFoundException: /Users/...../app/screenshots/screenshots-default/metadata.xml (No such file or directory)

Command Run : ./gradlew executeScreenshotTests -Pandroid.testInstrumentationRunnerArguments.class=testcases.Test0AppLaunch -Precord

Am I did any mistake ?
while running for the whole test suite its working fine.

@Serchinastico
Copy link
Contributor

Hi @arjungovindgv

I think I had this very same problem when the emulator didn't have write permissions for the sdcard or there was a major problem running tests (some sort of crash). Try deleting and creating the emulator again and see how it goes. Another thing to watch here is the facebook's dependency version.

You can find a working project here: https://github.com/Karumi/KataScreenshotKotlin. Try cloning the repo and executing ./gradlew executeScreenshotTests -Precord to see if it's a problem with the emulator or the library.

@arjungovindgv
Copy link
Author

arjungovindgv commented Mar 21, 2019

@Serchinastico If its a permission issue ? then how the entire test suite will run but not for it's very first test class.
I tried with Real Device too.. got the same problem

For my project too, its running perfect with ./gradlew executeScreenshotTests -Precord but not for the particular test method or class
Thanks for the immediate Reply

@Serchinastico
Copy link
Contributor

I meant write permissions as in the file system permissions, not in the AndroidManifest declaration way. Anyways it was just a wild guess as I'm lacking some context here. If I'm understanding your problem right it's that running a single test class fails with the "no such file..." error message, isn't it? Are you sure you are running the command with the whole package name + class name? As in

./gradlew clean executeScreenshotTests -Pandroid.testInstrumentationRunnerArguments.class=com.karumi.ui.view.MainActivityTest

Try running that on the sample project (https://github.com/Karumi/KataScreenshotKotlin) and see if it works. Once you run it we will know if the issue is in the emulator, in your project's configuration or the library itself.

@arjungovindgv
Copy link
Author

Hi @Serchinastico

Sample Project working fine. Even for my project test is running perfectly getting error in report generation part alone that too on running a particular class or method

Logcat trace :

Task :app:downloadScreenshots
?? Pulling screenshots from your connected device!

Task :app:executeScreenshotTests FAILED
? Comparing screenshots with previous ones.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:executeScreenshotTests'.

java.io.FileNotFoundException: /Users/..../app/screenshots/screenshots-default/metadata.xml (No such file or directory)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

@Serchinastico
Copy link
Contributor

If the project I linked you is working try comparing its dependencies and project configuration. More specifically, see if there is any difference in the 'com.facebook.testing.screenshot:core' version. Apart from that, I'm kind of lost here without more context. Can you send us a minimal project where the lib is not working so that we can see what's happening?

@arjungovindgv
Copy link
Author

arjungovindgv commented Mar 23, 2019

@Serchinastico can you share your mail ID where I can send those fails in private for detail ?

@Serchinastico
Copy link
Contributor

I'm afraid not, we try to offer support for the library, not your specific project. If you can create an open source minimal project replicating the issue we will be glad to help you and it will be way easier for us to spot the issue.

@arjungovindgv
Copy link
Author

I am having a test class under
/app/src/androidTest/java/testcases/TestClass

Build Gradle File Dependency

androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
// androidTestImplementation 'com.android.support:support-annotations:28.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-web:3.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-idling-resource:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.0'
androidTestImplementation 'org.assertj:assertj-core:2.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'

//spoon - report generator - automations
androidTestImplementation 'com.squareup.spoon:spoon-client:1.6.4'

// facebook
androidTestImplementation('com.facebook.testing.screenshot:core:0.4.2') {
exclude group: 'com.crittercism.dexmaker', module: 'dexmaker'
exclude group: 'com.crittercism.dexmaker', module: 'dexmaker-dx'
}

}
shot {
appId = "app Id*'
instrumentationTestTask = 'connectedPhoneDebugLocalAndroidTest'
packageTestApkTask = 'packagePhoneDebugLocalAndroidTest'

}
spoon{
singleInstrumentationCall = true
}

On running this command

./gradlew executeScreenshotTests -Pandroid.testInstrumentationRunnerArguments.class=testcases.TesClass -Precord

test is running fine and everthing works fine but for report generation I am getting

Task :app:downloadScreenshots
?? Pulling screenshots from your connected device!
Task :app:executeScreenshotTests FAILED
? Comparing screenshots with previous ones.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:executeScreenshotTests'.
java.io.FileNotFoundException: /Users/..../app/screenshots/screenshots-default/metadata.xml (No such file or directory)
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

@arjungovindgv
Copy link
Author

arjungovindgv commented Apr 1, 2019

@Serchinastico what more info should I have to provide ? If I run the whole test suite its working fine but getting while running a particular class or method

@arjungovindgv
Copy link
Author

@Serchinastico any update on this

@pedrovgs
Copy link
Owner

pedrovgs commented Apr 8, 2019

@arjungovindgv why are you using androidTestImplementation('com.facebook.testing.screenshot:core:0.4.2')? This might be the issue. Could you try removing this dependency?

On the other hand, could you check the test you are executing passes just running it from Android Studio? If the issue is not related to the lib version it has to be related with how the library is saving the screenshots and we'd need to know if the test pass from Android Studio.

@arjungovindgv
Copy link
Author

Finally after removing the dependency, it got worked.
Thank you so much @pedrovgs @Serchinastico

@pedrovgs
Copy link
Owner

You are welcome @arjungovindgv Thanks for using shot, we love seeing people writing tests!!!

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

3 participants