Skip to content

EarlGrey

bootstraponline edited this page Aug 14, 2018 · 16 revisions

React Native

  • Create shared scheme for React
  • Add React to Target Dependencies of test target build phases

Custom EarlGrey framework

  • Change custom framework's DYLIB_INSTALL_NAME_BASE from @rpath to @executable_path
    • CustomFramework target → Build SettingsDynamic Library Install Name Base
  • Add custom framework to CopyFilesBuildPhase in the app test target
    • EarlGrey.framework must also be in this Copy Files phase
  • Update DYLD_INSERT_LIBRARIES environment variable in the test target scheme to @executable_path/EarlGrey.framework/EarlGrey:@executable_path/CustomEarlGrey.framework/CustomEarlGrey
    • ProductSchemeManage Schemes...Edit...TestArgumentsEnvironment Variables

EarlGrey build config notes

  • DYLIB_INSTALL_NAME_BASE @rpath not @executable_path
  • LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; not $(PROJECT_DIR)/../Pods/Pods/EarlGrey/EarlGrey
  • IPHONEOS_DEPLOYMENT_TARGET set to 11.2 or below for Firebase Test Lab
  • FRAMEWORK_SEARCH_PATHS must include dir that contains the EarlGrey framework
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)

Install Ruby

$ brew update
$ brew install rbenv

Load rbenv automatically by appending the following to ~/.bash_profile or ~/.zshrc

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Now source bash profile or zshrc:

  • $ source ~/.bash_profile
  • $ source ~/.zshrc

and run the following commands:

$ rbenv install 2.3.3
$ rbenv global 2.3.3
$ echo "gem: --no-document" >> ~/.gemrc
$ gem update --system --no-document 
$ gem install --no-document bundler fastlane cocoapods

Now manually run rbenv init

If Ruby 2.3.3 still isn't on your path, try reinstalling ruby:

rbenv install 2.3.3

Optionally symlink /usr/local/bin/ruby to ~/.rbenv/shims/ruby which ensures system Ruby points to rbenv Ruby.

ln -snf ~/.rbenv/shims/ruby /usr/local/bin/ruby

react-native

  • Extend GREYInteraction not GREYElementInteraction otherwise there may be weird compile errors
  • Always use GREYCondition::waitWithTimeout:pollInterval: and not GREYCondition::waitWithTimeout otherwise the app may freeze due to the main thread getting blocked.
    • scanning the hierarchy with a pollInterval of zero will prevent the main thread from doing other work.

Loop a Swift test to check for stability

func testStability() {
  for _ in 1...1000 {
    setUp()
    // test code
    tearDown()
  }
}

objc runtime source code

Clone this wiki locally