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
Guide how to see screenshots in html report #251
Comments
Shouldn't it be |
closing, wrong flag used. please report back if it's still broken with --screenshots |
@supermarin @kirillzh with flag --screenshots doesn't work, it still only display a html without any screenshot. |
I am having the same issue, I cannot see the screenshots in my html reports with the --screenshots flag |
Hi! and i also have the same problem. Is there some workaround here? |
@supermarin, any update for this bug? Some users also met this issue? Hope it can be fixed asap, thanks. |
any update on this? |
have been seeing the same issue |
+1 |
Sorry for the silence here - everyone is welcome to look into this and submit a PR. |
Everyone here - mind confirming if @mattcotton's #269 fixes the issue? |
I tried running |
@smaljaar how are you generating the screenshots in the first place, and where are you storing them? Can you give me an example filename? |
@mattcotton Thanks for your response. That's a good point because I don't know. I thought xcpretty would find the screenshots that XCTest generates while running tests by itself. Now, from looking at your fix and your question to me, I'm guessing you have to provide the --path and create screenshots explicitly in your test run, and provide those screenshots with a specific name format. Then xcpretty will pick it up. Am I on the right track? I'll experiment with it, but I think it would be helpful if it was more explicitly documented how to get screenshots in the html report. |
@smaljaar no problem. I believe that the original PR was done with KIF testing in mind - KIF provides the ability to specify the location of captured screenshots. For the |
It actually looks like I have a further issue with #269 - it only works with the Test Suite names for tests written in Objective-C. It looks like tests written in Swift prepend the namespace to the Suite name which breaks the screenshot matching. I'll submit another PR later to resolve @supermarin |
Thank you for investigating @mattcotton! |
No problem @supermarin! I've submitted #270 which fixes my above comment - I didn't see yours regarding adding test cases but can add them if required? There are already test cases around screenshots, but based on a different file name scheme. I seem to have a failing test on #270 which I didn't have when running locally - any ideas? There is quite a difference in performance - 1.6s on my machine vs 2.3 on Travis... |
hello @mattcotton @supermarin So here is my use case : I only capture screenshots on failure with a custom name and in some custom directory. (I am writing my tests in SWIFT) But I understand to make --screenshots work I need to have all my screenshots in build/reports and with a "some specific" name. Now my question is : what should be the name look like? can you provide a sample? My test suite may have multiple methods. So is it like TestSuiteName_MethodName? I am looking for specific format --screenshots parses. Please suggest. Thanks in advance |
Can some one please respond to question above? Its critical at this point for me. |
@amirsh-jain yes the screenshots need to be in the build/reports directory - I may make this configurable in future. As described in #280, at the moment the screenshot filename needs to begin with the test method name. |
#280 now contains support for screenshots in a |
@mattcotton Could you please give an example of how to implement it... i am giving xcodebuild test [params] | xcpretty --report html --screenshots command but there are no screenshots in the report. Thanks for your help |
Does this look right? I dont see any screenshots in my html reports... xcodebuild test |
@pawankums, @tsaakyan both commands look fine, however, are you sure that your screenshots are stored in build/reports? At the moment this is the only supported location, and screenshot file names must begin with the test method name (optionally pretending the test suite name followed by an underscore) |
@mattcotton do you mean change screenshot save location? |
Yes exactly, at the moment the location that the report searches for screenshots isn't user configurable. I may submit a PR to add this. For now, save your screenshots to build/reports and give it another try. |
@mattcotton how to save the screenshots in xctest using swift. I used to think that XCtest takes the snapshots automatically. Please let me know, how can i save a screenshot in the build/reports location. |
If you supply the derivedDataPath argument to your xcodebuild test command, you can pass in build/reports as the path. E.g. Xcodebuild [...] -derivedDataPath 'build/reports' test XCTest screenshots will then be stored in the correct location. |
@mattcotton thanks, i was able to save the screenshots in the build/reports location but still i can't see them in the report for the failed scenarios. |
@pawankums can you give me and example of how the screenshots are named? |
@mattcotton screenshots are getting saved in build/reports/Logs/Test/Attchments/ as Screenshot_1E2229E4-6C31-49A3-9182-ED57F287E90B.png |
Would be nice if there would be a tutorial on how to set this up. |
+1 for this issue. Xcode generates screenshots to build/reports/Logs/Test/Attchments/ as Screenshot_[UID].png I've tried to generate screenshots itself using https://github.com/zmeyc/UITestUtils to build/reports with correct name, but still there is no screenshots in report( |
Found a solution for me. Will write it here, maybe it will help you too, guys.
then the screenshot name will be PartitaProtocolBDDTests.[TESTSUITE]_[TESTMETHOD].png e.g. PartitaProtocolBDDTests.SmokeTests_testUserCanClickStartButton.png hope it helps Also screenshots will be available in xcode 9, see https://developer.apple.com/documentation/xctest/xcuiscreenshot |
Hey @mattcotton I am little confused with your two different comment. About the file name format, In one comment above you mentioned And in other you mentioned can you confirm which one is correct? |
@aditjain xcpretty now supports screenshots named in either TESTSUITE_TESTMETHOD format, or just TESTMETHOD. @pawankums, @APshenkin as I've mentioned previously, the current implementation was written with KIF screenshots in mind, which names them in the above format and allows you to specify the location. At some point I will write this up and provide the ability to specify the location. However we have to have some standard naming scheme so that we can match to tests. |
This thread is one year almost, but I wanted to ask: does the screenshot have to be taken by us in each test case? xcpretty doesn't take it from |
Hey guys, we found a workaround for this issue, hopefully it will be useful to you.
This will name the screenshots something like: "testMyFeature_1_84B147E1-9981-4BX3-845F-AC49A4BF2E0X.png"
Hope this helps! |
@cvillalobos84 where do you put the script? and when its called? since report generated in one command with test i think this not possible? |
At what point do we call the script? |
We found a simple way to attach screenshots to HTML reports in current version of xcpretty using I just want to note that the correct name of the screenshot is:
We also made simple extension to |
u mean with this extension the screenshot will be automatically included to the xcpretty report? no manual call for |
No, it will not be included automatically on fail. We also use the report for quick visual checks before we release the app, so we also use the method manually. I can think of two solutions to this issue:
|
take a look at https://github.com/TitouanVanBelle/XCTestHTMLReport |
@here Do we have any update on this?, None of the above solutions worked for me |
Hi ,
I run my xcuitest via below command, but it can't see any screenshot in html report.
Please help how can get screenshots in html report.
Thanks.
Luis
The text was updated successfully, but these errors were encountered: