testing - Swift XCTest UI tests with Realm -
i'm developing ui test swift 3.0 using realm 2.4.2.
ui test target
- create realm object cat pk "cat_01"
- check if exists cat object pk "cat_01" -> success
- open view controller contains list of cats fetched realm -> empty list
application
- catslistviewcontroller: table view cats (no cat object found)
how can "see" both on test target , application same realm objects?
what not want using launcharguments workaround delegating app create objects.
you cannot "see" same realm objects in uitest target , application because 2 running separated processes.
from apple's docs:
ui testing exercises app's ui in same way users without access app's internal methods, functions, , variables. ... test code runs separate process, synthesizing events ui in app responds to.
in other words: uitests running in separate app interacts main app (when run uitest can see testrunner app being launched , closed before main app being launched). 2 apps can not share objects.
i see 2 directions go:
1. create cat objects via app's ui
somewhere have "add cat" button. press in uitest, add cat use , assert cat has been added list. uitests for. using app user , testing results of user's interaction app.
2. use unittests:
if want test created realm cat object populating list unittest might better way. during unittest have full access app's code. can create cat object in test code , app "see" it.
Comments
Post a Comment