earlgrey_使用CocoaPods将EarlGrey添加到您的iOS应用

earlgrey

EarlGrey is one of the more popular iOS UI testing frameworks. It is developed by Google, it is natively built on top of XCUITest and uses Google’s eDistantObject remote invocation system to function effectively.

EarlGrey是最受欢迎的iOS UI测试框架之一。 它是由Google开发的,它是本机在XCUITest之上XCUITest并使用Google的eDistantObject远程调用系统有效地起作用。

In this blog, I’m going to show how you can easily add it to your iOS project using CocoaPods.

在此博客中,我将展示如何使用CocoaPods将其轻松添加到iOS项目中。

EarlGrey2, the most recent version, is split into two components — the app side and the test side. These two components live in their respective areas, the app lives in the application under test, and the test side lives in the actual test itself and they interface with each other using eDistantObject.

EarlGrey2(最新版本)分为两个部分-应用程序端和测试端。 这两个组件位于各自的区域中,应用程序位于被测应用程序中,而测试端位于实际的测试本身中,并且它们使用eDistantObject相互连接。

Since there are two different components you are going to be including two different pods into your iOS project.

由于有两个不同的组件,因此您将在iOS项目中包含两个不同的Pod。

Let's say you’re making an iOS app called TheCatsApp. When you perform pod init on TheCatsApp a basic Podfile should be generated looking like this:

假设您要制作一个名为TheCatsApp的iOS应用。 在TheCatsApp上执行pod init ,应生成一个基本的Podfile,如下所示:

target 'TheCatsApp' doendtarget 'TheCatsAppUnitTests' doendtarget 'TheCatsAppUITests' doend

Where each target is a target as defined in your Xcode project. TheCatsApp target is your actual application and then the others are your unit and UI test targets respectively.

每个target都是Xcode项目中定义的目标。 TheCatsApp目标是您的实际应用程序,然后其他目标分别是您的单元和UI测试目标。

Since EarlGrey is a UI testing framework we’re going to be focusing on the application and UI test targets.

由于EarlGrey是UI测试框架,因此我们将重点关注应用程序和UI测试目标。

Update your Podfile adding in EarlGreyApp and EarlGreyTest like so:

更新您的Podfile在加入EarlGreyAppEarlGreyTest像这样:

target 'TheCatsApp' do   pod 'EarlGreyApp'endtarget 'TheCatsAppUnitTests' doendtarget 'TheCatsAppUITests' do   pod 'EarlGreyTest'end

Then run pod install on that directory to install those pods.

然后在该目录上运行pod install以安装这些pod。

As you can see we added EarlGreyApp to our application target, and we added EarlGreyTest to our UI test target. You may notice that we didn’t include a pod link to eDistantObject, that is because if you look at the Podspec for EarlGrey2 eDistantObject is already included as a dependency.

如您所见,我们将EarlGreyApp添加到了应用程序目标中,并且将EarlGreyTest添加到了UI测试目标中。 您可能会注意到,我们没有包含指向eDistantObject的pod链接,这是因为如果您查看EarlGrey2的Podspec ,则eDistantObject已经作为依赖项包含在内。

Once you’ve run pod install you’ve successfully added EarlGrey to your iOS app!

运行pod install您已成功将EarlGrey添加到iOS应用中!

To add it to your Objective-C UI tests you can import it like #import <EarlGreyTest/EarlGrey.h>. To use EarlGrey on Swift UI tests, you simply need to add the EarlGrey Swift Wrapper and add a bridging header as shown in the EarlGrey docs.

要将其添加到Objective-C UI测试中,您可以像#import <EarlGreyTest/EarlGrey.h>一样将其导入。 要在Swift UI测试中使用EarlGrey,您只需添加EarlGrey Swift包装器并添加桥接头,如EarlGrey docs所示。

There is also an example project here that has demo code all setup that shows everything I’ve explained here.

这里还有一个示例项目其中包含所有设置的演示代码,显示了我在此处说明的所有内容。

Happy coding!

编码愉快!

翻译自: https://itnext.io/adding-earlgrey-to-your-ios-app-with-cocoapods-918d4ce1dfd0

earlgrey

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值