2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

xcode+gradle xcode pluginでUnitTest実行

Last updated at Posted at 2015-04-28

環境

  • xcode6.3
  • gradle2.3

前提条件

  • 対象のXcodeプロジェクトでXCTestを使ったユニットテストがGUIから実行出来る状態になっていること

スクリプト

UT実行に必要な最小限のgradleスクリプトは以下の通り。

build.gradle
buildscript {
  repositories {
    maven {
      url('http://repository.openbakery.org/')
    }
    mavenCentral()
  }
  dependencies {
    classpath group: 'org.openbakery', name: 'xcodePlugin', version: '0.10.3'
  }
}
apply plugin: 'xcode'

xcodebuild {
  scheme = 'Sample'
  sdk = "iphonesimulator"

  // destinationに何も指定しなければ、全てのシミュレータでテストが実行される。
  destination {
    os = '8.3'
    platform = 'iOS Simulator'
    name = 'iPhone 6'
  }
}

上記をxcodeprojと同階層に配置し、gradle testのコマンドを実行すると、XcodeのUnitTestが実行される。

$ gradle test    
:keychainClean
:keychainCreate SKIPPED
:provisioningClean
:provisioningInstall SKIPPED
:xcodebuildConfig
Parse project file: /Users/mikesorae/Documents/Sample/Sample.xcodeproj/project.pbxproj
:test

Start unit tests


Perform unit tests for: iPhone 6/iOS Simulator/8.3

      OK -[SampleTests.SampleTests testExample] - (0.000 seconds)
      OK -[SampleTests.SampleTests testPerformanceExample] - (0.331 seconds)
      OK -[SampleTests.SampleTests testVendor] - (0.000 seconds)


Tests finished: iPhone 6/iOS Simulator/8.3


All 3 tests were successful
Done

BUILD SUCCESSFUL
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?