84
#CLRH78 Tsuyoshi Maehana @sandinist 継続的インテグレーション iPhone アプリ開発でも 仕事で使える! 13120日日曜日

CLR/H78 CI at iOS

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: CLR/H78 CI at iOS

#CLRH78Tsuyoshi Maehana

@sandinist

継続的インテグレーション

iPhoneアプリ開発でも

仕事で使える!

13年1月20日日曜日

Page 2: CLR/H78 CI at iOS

Self Intro

• Tsuyoshi Maehana

• @sandinist

• Objective-C, Ruby, C#, VB.net

• ♥Ruby

• ♥Agile

13年1月20日日曜日

Page 3: CLR/H78 CI at iOS

@sandinist

@jcoplien

13年1月20日日曜日

Page 4: CLR/H78 CI at iOS

侍SamuraiEpisode

13年1月20日日曜日

Page 5: CLR/H78 CI at iOS

RubySapporo

13年1月20日日曜日

Page 6: CLR/H78 CI at iOS

Agile

Sapporo

13年1月20日日曜日

Page 7: CLR/H78 CI at iOS

SoupCurry♥

13年1月20日日曜日

Page 8: CLR/H78 CI at iOS

#CLRH78Tsuyoshi Maehana

@sandinist

継続的インテグレーション

iPhoneアプリ開発でも

仕事で使える!

13年1月20日日曜日

Page 9: CLR/H78 CI at iOS

チームに感謝を

13年1月20日日曜日

Page 10: CLR/H78 CI at iOS

Table of Contents

• Unit Tests

• Acceptance Tests

• Continuous Integration

iOSin13年1月20日日曜日

Page 11: CLR/H78 CI at iOS

iOS Development

• XCode

• iOS Developer Program

• Objective-C

Note

13年1月20日日曜日

Page 12: CLR/H78 CI at iOS

Use Version Control?

•Git•Mercurial•Bazaar• ...etc

!

13年1月20日日曜日

Page 13: CLR/H78 CI at iOS

AutomationTestingVersionControl

Three Pillar

13年1月20日日曜日

Page 14: CLR/H78 CI at iOS

Use Version Control.

•Git•Mercurial•Bazaar• ...etc

XCode Standard

13年1月20日日曜日

Page 15: CLR/H78 CI at iOS

Table of Contents

• Unit Tests

• Acceptance Tests

• Continuous Integration

iOSin13年1月20日日曜日

Page 16: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

Jenkinsgit

(bare)git

XCode &Instruments

ircdirc

VC& irc Linux

13年1月20日日曜日

Page 17: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

Jenkinsgit

(bare)git

XCode &Instruments

ircdirc

VC& irc Linuxpush

13年1月20日日曜日

Page 18: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

Jenkinsgit

(bare)git

XCode &Instruments

ircdirc

VC& irc Linuxhook

13年1月20日日曜日

Page 19: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

Jenkinsgit

(bare)git

XCode &Instruments

ircdirc

VC& irc Linux

Run Tests

13年1月20日日曜日

Page 20: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

Jenkinsgit

(bare)git

XCode &Instruments

ircdirc

VC& irc Linux

Notify

13年1月20日日曜日

Page 21: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

Jenkinsgit

(bare)git

XCode &Instruments

ircdirc

VC& irc Linux

Notify

13年1月20日日曜日

Page 22: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

Jenkinsgit

(bare)git

XCode &Instruments

ircdirc

VC& irc Linux

13年1月20日日曜日

Page 23: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

Jenkinsgit

(bare)git

XCode &Instruments

ircdirc

push hook

Run Tests

NotifyNotify

VC& irc Linux

13年1月20日日曜日

Page 24: CLR/H78 CI at iOS

Table of Contents

• Unit Tests

• Acceptance Tests

• Continuous Integration

iOSin13年1月20日日曜日

Page 25: CLR/H78 CI at iOS

AutomationTestingVersionControl

Three Pillar

13年1月20日日曜日

Page 26: CLR/H78 CI at iOS

what’s kinds of?

•Unit

• Integration

• Functional

• Join

•Acceptance

13年1月20日日曜日

Page 27: CLR/H78 CI at iOS

what’s kinds of?

•Unit

• Integration

• Functional

• Join

•Acceptance

For Developer

13年1月20日日曜日

Page 28: CLR/H78 CI at iOS

what’s kinds of?

•Unit

• Integration

• Functional

• Join

•Acceptance For Customer

13年1月20日日曜日

Page 29: CLR/H78 CI at iOS

what’s kinds of?

•Unit

• Integration

• Functional

• Join

•Acceptance

•NonFunctional For QA13年1月20日日曜日

Page 30: CLR/H78 CI at iOS

To Do in the UnitTests

•Models

•Own Libraries

•Communications

13年1月20日日曜日

Page 31: CLR/H78 CI at iOS

Not Do the UnitTests

•Views

•ViewControllers

•External Libraries

•Built-in Libraries

13年1月20日日曜日

Page 32: CLR/H78 CI at iOS

Table of Contents

• Unit Tests

• Acceptance Tests

• Continuous Integration

iOSin13年1月20日日曜日

Page 33: CLR/H78 CI at iOS

Unit Tests Frameworks.

•SenTestingKit

•GHUnit

•Cedar

•Kiwi

13年1月20日日曜日

Page 34: CLR/H78 CI at iOS

Unit Tests Frameworks.

•SenTestingKit

•GHUnit

•Cedar

•Kiwi

13年1月20日日曜日

Page 35: CLR/H78 CI at iOS

We use.

SenTesting

GHUnitKiwi

2010 2011 2012 2013

Is troublesome..

13年1月20日日曜日

Page 36: CLR/H78 CI at iOS

SenTestingKit

• XCode Standard

•Poor Matcher?

•Can’t Mocking?

•Async Difficult?

• Fixture there?

13年1月20日日曜日

Page 37: CLR/H78 CI at iOS

Poor Matcher?

•OCHamcrest • https://github.com/hamcrest/OCHamcrest

allOfequalTosameInstancehasItemcloseTolessThanendsWith...

13年1月20日日曜日

Page 38: CLR/H78 CI at iOS

Can’t Mocking?

•OCMock• https://github.com/erikdoe/ocmock

13年1月20日日曜日

Page 39: CLR/H78 CI at iOS

OCMock Attention

• Can’t Partial Mocking toll-free bridge Classes.

• Use mockForClass

13年1月20日日曜日

Page 40: CLR/H78 CI at iOS

• Double Pointer Argument

• Use OCMOCK_ANYPTR Macro.

• ex)• error:OCMOCK_ANYPTR(NSError *)

OCMock Attention

13年1月20日日曜日

Page 41: CLR/H78 CI at iOS

• union Argument is Can’t Stub.

OCMock Attention

13年1月20日日曜日

Page 42: CLR/H78 CI at iOS

Async Difficult?

•SenAsyncTestCase • https://github.com/akisute/SenAsyncTestCase

13年1月20日日曜日

Page 43: CLR/H78 CI at iOS

Fixture there?

Tell me!

13年1月20日日曜日

Page 44: CLR/H78 CI at iOS

Fixture there?

Make It!

13年1月20日日曜日

Page 45: CLR/H78 CI at iOS

Other Topic

•Method Swizzling

• ex) NSDate date

•Use JRSwizzle• https://github.com/rentzsch/jrswizzle

13年1月20日日曜日

Page 46: CLR/H78 CI at iOS

Our Rule

• 1 to 1 test class to class

• No Device Access (In Mock All)

• No Really Communicate (In Mock All)

• To Succeed xcodebuild

• Wait during asynchronous test as short as possible

• Do not write tests of getter / setter

13年1月20日日曜日

Page 47: CLR/H78 CI at iOS

13年1月20日日曜日

Page 48: CLR/H78 CI at iOS

13年1月20日日曜日

Page 49: CLR/H78 CI at iOS

Take a Break..

13年1月20日日曜日

Page 50: CLR/H78 CI at iOS

13年1月20日日曜日

Page 51: CLR/H78 CI at iOS

_人人人人人人_> 突然の縄 <‾Y^Y^Y^Y^Y‾

13年1月20日日曜日

Page 52: CLR/H78 CI at iOS

13年1月20日日曜日

Page 53: CLR/H78 CI at iOS

Table of Contents

• Unit Tests

• Acceptance Tests

• Continuous Integration

iOSin13年1月20日日曜日

Page 54: CLR/H78 CI at iOS

To Do in the Acceptance Tests

•User Action

•Running the Scenario

13年1月20日日曜日

Page 55: CLR/H78 CI at iOS

Acceptance Tests Framework

•UIAutomation

•Kif

• Frank

• FoneMonkey

•Zucchini13年1月20日日曜日

Page 56: CLR/H78 CI at iOS

Acceptance Tests Framework

•UIAutomation +tuneup.js

•Kif

• Frank

• FoneMonkey

•Zucchini13年1月20日日曜日

Page 57: CLR/H78 CI at iOS

Instruments

13年1月20日日曜日

Page 58: CLR/H78 CI at iOS

UIAutomation + tuneup.js

13年1月20日日曜日

Page 59: CLR/H78 CI at iOS

UIAutomation + tuneup.js

13年1月20日日曜日

Page 60: CLR/H78 CI at iOS

Acceptance Tests Framework

•UIAutomation +tuneup.js

•Kif

• Frank

• FoneMonkey

•Zucchini13年1月20日日曜日

Page 61: CLR/H78 CI at iOS

KIF

• KIF iOS Integration Testing Framework

• https://github.com/square/KIF

13年1月20日日曜日

Page 62: CLR/H78 CI at iOS

AutomationTestingVersionControl

Three Pillar

13年1月20日日曜日

Page 63: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

git(bare)git

XCode &Instruments

push

Run Tests

VC& irc Linux

13年1月20日日曜日

Page 64: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

Jenkinsgit

(bare)git

XCode &Instruments

ircdirc

push hook

Run Tests

NotifyNotify

VC& irc Linux

13年1月20日日曜日

Page 65: CLR/H78 CI at iOS

Automation

• Jenkins

• TeamCity

•CruiseControl.rb

• zapp

• buildbot13年1月20日日曜日

Page 66: CLR/H78 CI at iOS

Jenkins

13年1月20日日曜日

Page 67: CLR/H78 CI at iOS

Jenkins

• Building/testing software projects continuously

• Work with version controls

• Many Plug-in

• Easy to Install & Configure

• Run Any Scripts13年1月20日日曜日

Page 68: CLR/H78 CI at iOS

Jenkins Plug-ins

• Jenkins Git Plugin

• Jenkins IRC Plugin

• Parameterized Job Plugin

13年1月20日日曜日

Page 69: CLR/H78 CI at iOS

Proxy Setting

• Manage Jenkins

• System Setting

• Global Properties

• Environment Variable ON

• set http_proxy etc

!

13年1月20日日曜日

Page 70: CLR/H78 CI at iOS

Run Test from the Command Line

• xcodebuild

• instruments

• xcrun

13年1月20日日曜日

Page 71: CLR/H78 CI at iOS

Run Unit Tests

xcodebuild -scheme CLRHTest -sdk iphonesimulator TEST_AFTER_BUILD=YES -configuration Release

clean build

13年1月20日日曜日

Page 72: CLR/H78 CI at iOS

Run Unit Tests

xcodebuild -scheme CLRHTest -sdk iphonesimulator TEST_AFTER_BUILD=YES -configuration Release

clean build

CleanSetting Build Test

13年1月20日日曜日

Page 73: CLR/H78 CI at iOS

Run Acceptance Tests

APP="$(pwd)/build/Release-iphonesimulator/CLRH.app"

TEMPLATE=`instruments -s 2>&1 > /dev/null |sed -n 's/ *"\([^",]*\/Automation.tracetemplate\)",*/\1/p'`

SCRIPTS="$(pwd)/AcceptanceTest/*.js"

for SCRIPT in $SCRIPTSdo instruments -t $TEMPLATE $APP -e UIASCRIPT $SCRIPT if [ "$?" -ne 0 ]; then exit $? fidone13年1月20日日曜日

Page 74: CLR/H78 CI at iOS

Run Acceptance Tests

APP="$(pwd)/build/Release-iphonesimulator/CLRH.app"

TEMPLATE=`instruments -s 2>&1 > /dev/null |sed -n 's/ *"\([^",]*\/Automation.tracetemplate\)",*/\1/p'`

SCRIPTS="$(pwd)/AcceptanceTest/*.js"

for SCRIPT in $SCRIPTSdo instruments -t $TEMPLATE $APP -e UIASCRIPT $SCRIPT if [ "$?" -ne 0 ]; then exit $? fidone

"/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/

AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate"

13年1月20日日曜日

Page 75: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

Jenkinsgit

(bare)git

XCode &Instruments

ircdirc

push hook

Run Tests

NotifyNotify

VC& irc Linux

13年1月20日日曜日

Page 76: CLR/H78 CI at iOS

git hook

13年1月20日日曜日

Page 77: CLR/H78 CI at iOS

Eco!

#!/bin/bashwol '[MAC ADDRESS]'

for i in {0..5} doping -c1 host > /dev/nullif [ $? == 0 ]; then

breakfi

sleep 1done

wget --no-proxy -q "http://host:8080/job/Start/build?token=[token]&delay=0" if [ "$?" -eq 0 ]; then

echo "Jenkins build run."else

echo "Jenkins build failed."fi

13年1月20日日曜日

Page 78: CLR/H78 CI at iOS

Overview - Team Continuous Integration

Dev Mac CI Mac

Jenkinsgit

(bare)git

XCode &Instruments

ircdirc

push hook

Run Tests

NotifyNotify

VC& irc Linux

13年1月20日日曜日

Page 79: CLR/H78 CI at iOS

xcrun?

xcodebuild -project ./CLRH.xcodeproj clean build

xcrun -sdk iphoneos PackageApplication -v ./build/Release-iphoneos/CLRH.app -o "`pwd`/CLRH.ipa"

Set Valid Distribution Identifier for Release Build.

13年1月20日日曜日

Page 80: CLR/H78 CI at iOS

Continuous Delivery

• Use xcrun our case is all done manually.

• In no constraint case, you can use Testflight.

13年1月20日日曜日

Page 81: CLR/H78 CI at iOS

Overview - Release Continuous Delivery

Dev Mac VC Linux CI Mac

Jenkinsgit

(bare)git

XCode &Instrumentsweb

browser

VC Linux

git

Repositorybrowser

Destination

13年1月20日日曜日

Page 82: CLR/H78 CI at iOS

Overview - Release Continuous Delivery

Dev Mac VC Linux CI Mac

Jenkinsgit

(bare)git

XCode &Instrumentsweb

browser

push polling

VC Linux

Run Tests

git

Repositorybrowser

push

DLDestination

13年1月20日日曜日

Page 83: CLR/H78 CI at iOS

13年1月20日日曜日

Page 84: CLR/H78 CI at iOS

Any Auestion?

;-)

13年1月20日日曜日