TESTING EN IOS PUCELA TESTING DAYS JORGE MAROTO GARCÍA (@PATOROCO) AGILECYL - 30 NOVIEMBRE 2013
Jun 27, 2015
T E S T I N G E N I O SP U C E L A T E S T I N G D A Y S
J O R G E M A R O T O G A R C Í A ( @ PA T O R O C O ) A G I L E C Y L - 3 0 N O V I E M B R E 2 0 1 3
Jorge Maroto García.
[xxx]-Developer
+3 años jugando con iOS.
Fanboy.
Hola
D I S C L A I M E R
• Charla introductoria.
• Presentación CDD(Coffee Driven Development).
• Playback.
• Tiempo indeterminado.
D I S C L A I M E R
X C O D E . E L I D E .
F R A M E W O R K S D E T E S T I N G
• OCUnit (< iOS7)
• XCTest (iOS7)
• GHUnit (https://github.com/gh-unit/gh-unit)
O C U N I T
STAssertTrue(expression, msg, ...)STAssertEqualObjects(a1, a2, msg, ...)
STAssertEquals(a1, a2, msg, ...)STAssertEqualsWithAccuracy(a1, a2, msg, ...)
STFail(msg, ...)STAssertNil(a1, msg, ...)
STAssertNotNil(a1, msg, ...)STAssertTrueNoThrow(expression, msg, ...)
STAssertFalse(expression, msg, ...)STAssertFalseNoThrow(expression, msg, ...)
STAssertThrows(expression, msg, ...)STAssertThrowsSpecific(expression, exception, msg, ...)
STAssertThrowsSpecificNamed(expression, exception, name, msg, ...)STAssertNoThrow(expression, msg, ...)
STAssertNoThrowSpecific(expression, exception, msg, ...)STAssertNoThrowSpecificNamed(expression, exception, msg, ...)
X C T E S T
XCTFail (format…)XCTAssertNil (a1, format…)
XCTAssertNotNil (a1, format…)XCTAssert (a1, format…)
XCTAssertTrue (a1, format…)XCTAssertFalse (a1, format…)
XCTAssertEqualObjects (a1, a2, format…)XCTAssertEquals (a1, a2, format…)
XCTAssertEqualsWithAccuracy (a1, a2, accuracy, format…)XCTAssertThrows (expression, format…)
XCTAssertThrowsSpecific (expression, specificException, format…)XCTAssertThrowsSpecificNamed (expression, specificException, exceptionName, format…)
XCTAssertNoThrow (expression, format…)XCTAssertNoThrowSpecific (expression, specificException, format…)
XCTAssertNoThrowSpecificNamed (expression, specificException, exceptionName, format…)
T E S T L I F E C Y C L E
• +(void)setup
• +(void)tearDown
• -(void)setup
• -(void)tearDown
• -(void)test<whatever>
T D D . C A L C U L AT O R 3 0 0 0 .
M I E N T R A S TA N T O E N E L M U N D O R E A L …
C L A S E S D E U T I L I D A D
E J E M P L O R E A L : M A P E A R J S O N
E J E M P L O R E A L : M A P E A R J S O N
E J E M P L O R E A L : T O R P E Z A
E J E M P L O R E A L : T O R P E Z A
E J E M P L O R E A L : T O R P E Z A
E J E M P L O R E A L : S I N G L E T O N
• API en singleton.
• I de FIRST.
• ¿Cómo inyecto la API en un test?
E J E M P L O R E A L : S I N G L E T O N
• API en singleton.
• I de FIRST.
• ¿Cómo inyecto la API en un test?
• Ideaca: usar @property para apuntar a la API y así puedo ‘allocar’ un singleton distinto en cada test.
E J E M P L O R E A L : S I N G L E T O N
• API en singleton.
• I de FIRST.
• ¿Cómo inyecto la API en un test?
• Ideaca: usar @property para apuntar a la API y así puedo ‘allocar’ un singleton distinto en cada test.
• Consecuencias: subclasear para testing.
C H A P U ZA
¡ A Ú N Q U E D A E S P E R A N Z A !
https://github.com/jonreid/OCMockito
O C M O C K I T O : I N S TA L A C I Ó N
*Presentación CocoaPods: http://maroto.me/ttzc
O C M O C K I T O : I N S TA L A C I Ó N
O C M O C K I T O : E J E M P L O S
O C M O C K I T O : E J E M P L O S
O C H A M C R E S T: M AT C H E R S
https://github.com/hamcrest/OCHamcrest
Ejemplo de matchers:
U N PA S I T O M Á S . K I W I .
https://github.com/allending/Kiwi
K I W I : I N S TA L A C I Ó N
K I W I : U S O
K I W I : E J E M P L O S
K I W I : E J E M P L O S
K I W I : E J E M P L O S
U I A U T O M AT I O N
D E M O
http://maroto.me/vu7f
M O L A N D O
http://vimeo.com/39888743
T E S T E A N D O M I E N T R A S D U E R M E S .
T R AV I S
• Gratuito para proyectos open source.
• Integrado con github.
• .travis.yml
https://travis-ci.org/patoroco/JMGFrame
J E N K I N S E S PA R A P O B R E S
O S X S E R V E R
Tutorial para montar bots: http://maroto.me/vu7h
GRAC IAStwitter: @patoroco
git.jorgemaroto.es
in.jorgemaroto.es
jorgemaroto.es