[ios] add unit test target #7740
No reviewers
Labels
No labels
Accessibility
Accessibility
Address
Address
Android
Android
Android Auto
Android Auto
Android Automotive (AAOS)
Android Automotive (AAOS)
API
API
AppGallery
AppGallery
AppStore
AppStore
Battery and Performance
Battery and Performance
Blocker
Blocker
Bookmarks and Tracks
Bookmarks and Tracks
Borders
Borders
Bug
Bug
Build
Build
CarPlay
CarPlay
Classificator
Classificator
Community
Community
Core
Core
CrashReports
CrashReports
Cycling
Cycling
Desktop
Desktop
DevEx
DevEx
DevOps
DevOps
dev_sandbox
dev_sandbox
Directions
Directions
Documentation
Documentation
Downloader
Downloader
Drape
Drape
Driving
Driving
Duplicate
Duplicate
Editor
Editor
Elevation
Elevation
Enhancement
Enhancement
Epic
Epic
External Map Datasets
External Map Datasets
F-Droid
F-Droid
Fonts
Fonts
Frequently User Reported
Frequently User Reported
Fund
Fund
Generator
Generator
Good first issue
Good first issue
Google Play
Google Play
GPS
GPS
GSoC
GSoC
iCloud
iCloud
Icons
Icons
iOS
iOS
Legal
Legal
Linux Desktop
Linux Desktop
Linux packaging
Linux packaging
Linux Phone
Linux Phone
Mac OS
Mac OS
Map Data
Map Data
Metro
Metro
Navigation
Navigation
Need Feedback
Need Feedback
Night Mode
Night Mode
NLnet 2024-06-281
NLnet 2024-06-281
No Feature Parity
No Feature Parity
Opening Hours
Opening Hours
Outdoors
Outdoors
POI Info
POI Info
Privacy
Privacy
Public Transport
Public Transport
Raw Idea
Raw Idea
Refactoring
Refactoring
Regional
Regional
Regression
Regression
Releases
Releases
RoboTest
RoboTest
Route Planning
Route Planning
Routing
Routing
Ruler
Ruler
Search
Search
Security
Security
Styles
Styles
Tests
Tests
Track Recording
Track Recording
Translations
Translations
TTS
TTS
UI
UI
UX
UX
Walk Navigation
Walk Navigation
Watches
Watches
Web
Web
Wikipedia
Wikipedia
Windows
Windows
Won't fix
Won't fix
World Map
World Map
No milestone
No project
No assignees
2 participants
Due date
No due date set.
Dependencies
No dependencies set.
Reference: organicmaps/organicmaps-tmp#7740
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "ios/add-test-target"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds the
Unit test target
to iOS.How to add unit tests
The easiest way to add some tests:
select in the XCode
File -> New -> File...
find and select
Unit Test Case Class
pay attention that

OMapsTest
target is selectedSave into
Tests
directoryAdd the line
@testable import Organic_Maps__Debug_
belowimport XCTest
to get access to all OM public and internal classes.Write your tests
Select a simulator as a run destination to run test cases.
Example of use
As an example the test case for the
CarPlayService
methodcreateEstimates
(thanks to @fabwu for fix) was added:Before the fix we can see that test case the with coma-separator used for the distace initialization fails and with dot passes:

After fix (using the double instead of the string):

Important
At least one issue should be resolved to merge this PR:
When we run testcases and they are finished, the app fails with error in the
SharedBufferManager
:You still can see passed/failed tests but error is annoying. This bug may affect async tests.
It would be clearer to disable this call where it has originated:
Maybe like this?
@ -4598,1 +4664,4 @@
};
ED097E7C2BB80C330006ED01 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 347526FA1DC0B00F00918CF5 /* common-debug.xcconfig */;
These settings should come from the common, release and debug configs, like it's done in other configurations in this project.
@ -30,0 +39,4 @@
<CommandLineArguments>
<CommandLineArgument
argument = "-IsTests"
isEnabled = "YES">
On the second thought, we already know if tests are launched either from XCode or from command line, even without that parameter, right?
Are env vars or command line params used in the final solution?
@ -30,0 +39,4 @@
<CommandLineArguments>
<CommandLineArgument
argument = "-IsTests"
isEnabled = "YES">
Yes! This launch arg is used only during the test run started by both xcode and console.
@ -4598,1 +4664,4 @@
};
ED097E7C2BB80C330006ED01 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 347526FA1DC0B00F00918CF5 /* common-debug.xcconfig */;
All settings are following the
common.xcconfig
. When I change this or other settings and save the file - they all will be automatically updated.The fact that the property is set here with the concrete value - this is how xcconfig works:
I have code signing issues when running it. Does it work fine for you on the simulator and the device?
Is it the latest Xcode?
@ -4598,1 +4664,4 @@
};
ED097E7C2BB80C330006ED01 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 347526FA1DC0B00F00918CF5 /* common-debug.xcconfig */;
app.organicmaps.tests
app.organicmaps.tests
Did you test it in Release?
No. Latest is 15.3. Should this line be removed?
Removed form .pbxproj
A few more comments. If it works on your device, let's move on with merging then.
It would be great to run tests also on Mac, without any simulator, we can do it later.
This line should be removed, it is duplicated below.
@ -4596,6 +4662,35 @@
};
@ -30,0 +39,4 @@
<CommandLineArguments>
<CommandLineArgument
argument = "-IsTests"
isEnabled = "YES">
Maybe make it more explicit, like -disableDrape ?
Thanks! Let it 🪰