-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Initial tests setup #422
Initial tests setup #422
Conversation
Force pushed the branch. I was using wrong version of cocoapods by a mistake. |
bravo! First time knowing snapshot testing. It seems like using image recognition? How about the accuracy? And, it's fully automated? |
BTW, what's the special for nimble? It's saying |
It's just pixel by pixel comparison. Here is the source if you'd like to see how exactly it's implemented :)
Exactly! :) You will get a failing test.
There is a library by FB called FBSnapshotTestCase. It has FBSnapshotTestController class which does all important things: renders a UIView or CALayer to an image, can store this image into a reference directory (when you run tests in record mode), read a reference image from the disk and compares it pixel by pixel to another image... Also there is
No worries at all! Keep asking 👍 |
Oops... This was closed by mistake, by mentioning the wrong issue number |
@yas375 I'm having trouble with this, as currently if the user has not installed the required modules for unit tests - it does not compile the framework at all... |
@danielgindi libs required for unit tests are added using CocoaPods and they are stored in |
Have you tried openingthe xcodeproj and compiling normally? It fails... בתאריך יום חמישי, 1 באוקטובר 2015, Victor Ilyukevich <
|
If you are talking about
Here is a description of what CocoaPods make behind the scenes. Please don't hesitate to ask in case you have any questions. I'm really interested in getting this merged in and improving test coverage of the library :) |
@danielgindi sorry for reminding, any thoughts on this work? Want me to rebase this on master? |
I still have the compatibility issue with native Xcode. When compiling - it shows red errors about "No such module 'Quick'". |
Ya that is because you need to run pod install and use the workspace instead of the project. |
UI testing would be good since it would be easier to test scrolling the chart and such. I haven't used it much at all so I don't know what is possible. |
Are you sure you are opening xcworkspace and not the xcodeproj file? You shouldn't see this if you are opening workspace. The workspace has two projects in it. If you'd like we can have a call with screen sharing. I'd be happy to help :)
You don't need to run
It's a good thing to have. I don't think it's correct to say "I'd like to move from unit tests to UI tests". Both types of tests are important and both have pros and cons. I usually make more accent on unit tests because they give quicker feedback and help to design nice code. Especially if you are trying to to TDD. It's usually a lot harder to write a UI test first. You can also see that I had a note in the PR's description about adding UI tests in future ;) |
Well, I WANT to open the xcodeproj file, as the users open the project בתאריך יום שישי, 16 באוקטובר 2015, Victor Ilyukevich <
|
Moving to a workspace does have advantages. For example, right now there are 2 projects (charts and demo). Those could be in the same workspace. Otherwise if you really want to just keep the project then using Carthage to install quick would work to do that. Otherwise moving to xctest is doable. |
I don't think using workspace is a "workaround". It's feature Xcode has for ages. I can't remember when I was opening xcodeproj for the last time... I'm looking for a workspace file by default when I need to open a new project... Why is it considered a bad thing? I was aiming to make this all simple: "open workspace & run tests". You don't need to install anything else. All helpful libraries for testing are already there. Lots (or maybe most?) of developers are using CocoaPods and already familiar with it. It shouldn't be a problem. |
Based on the types of issues that are opened for this repository I believe that a lot of users that are using this library are somewhat beginners to iOS and it might be hard for them to understand workspaces and cocoapods if they have never seen it before. It is possible to use quick and such without cocoapods so it shouldn't be an issue to move to just a project. |
Anyway, for me if I download a project, double click the projectand Also many people don't like CocoaPods. I for once don't use it. I feel like |
You don't have to right click a project file to find a workspace. It's just like a project file. Just click it in the folder structure. But I understand your other points and they are very valid. So Carthage it is or move to xctest. |
Does anybody know if FBSnapshotTestCase and Nimble-Snapshots can be added using Carthage? I don't see anything about Carthage in theirs readmes... @danielgindi I didn't use Carthage before, but can spend some time to redo this pull request using Carthage if you are interested in. |
As long as there is an Xcode project in the root of th github repo it should just work. Even if they don't mention it in the readme |
Closes #414
Here is some initial work on adding unit tests to the project.
To run unit tests
ChartsDemo/ChartsDemo.xcworkspace
(not.xcodeproj
!). Also please use the workspace if you are contributing to the library.[email protected]
.Useful resources for contributors
About snapshot testing
Snapshot testing means generating images of the view and storing them as reference images. When tests are running another image is generated from the view and compared with the reference images.
This is achieved with these two libs:
When you need to regenerate a snapshot image replace next line
with
Note about warnings when running unit tests
When you run tests from Xcode 7 you will probably see 4 warnings like the next one:
This has been fixed in CocoaPods here: CocoaPods/CocoaPods#4219 and will be included in a next CocoaPods release.
Next steps (happy to discuss)
I'm open for any feedback and happy to answer any questions regarding decisions being made while working on this.