Skip to content

Latest commit

ย 

History

History
96 lines (58 loc) ยท 3.53 KB

Advanced-Testing-and-Continuous-Integration.md

File metadata and controls

96 lines (58 loc) ยท 3.53 KB

Advanced Testing and Continuous Integration

Session 409

๐Ÿ”— Advanced Testing and Continuous Integration - WWDC 2016 - Videos - Apple Developer

Testing Concepts

Test Hosting

Unit Tests ์˜ ๊ฒฝ์šฐ, test bundle ์ด application์— ์ง์ ‘์ ์œผ๋กœ load๋œ๋‹ค (application ์„ Host Application์ด๋ผ๊ณ  ๋ถ€๋ฆ„)

UI Tests ์˜ ๊ฒฝ์šฐ, test bundle์ด ์•ฑ๊ณผ ๋ถ„๋ฆฌ๋œ UI test runner๋กœ test bunlde์ด load ๋œ๋‹ค (application ์„ Target Application)

Unit Tests

  • ์•ฑ์˜ ์ž๋ฃŒ ๊ตฌ์กฐ, API ๋ฅผ ์ง์ ‘์ ์œผ๋กœ ์ ‘๊ทผ
  • host application์˜ ๊ฐ™์€ ์‹คํ–‰ ์•„๋ž˜์„œ ์ž‘๋™
  • ๊ทธ๋ž˜์„œ test invocation ์‚ฌ์ด์—์„œ clean up ํ•ด์ฃผ์–ด์•ผํ•จ

UI Tests

  • Accessibility๋ฅผ ํ†ตํ•ด ์•ฑ์— ์ ‘๊ทผ, ์•ฑ์— event๋ฅผ ๋ณด๋‚ด๊ณ , ์™ธ๋ถ€์—์„œ ์œ ์ €๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ ์ฒ˜๋Ÿผ ๋ด์•ผํ•จ
  • ํ…Œ์ŠคํŠธ๊ฐ€ terminate๋˜๊ณ  relaunch ๋  ์ˆ˜ ์žˆ๋‹ค

Test Observation

XCTestObservation Protocol

protocol์„ ๋”ฐ๋ฅด๊ณ  shared observation center์— ๋“ฑ๋ก ํ•˜๋ฉด call back์„ ๋ฐ›๋Š”๋‹ค

    override init() {
    	super.init()
    	
    	let sharedCenter = XCTestObservationCenter.shared()
    	sharedCenter.addTestObserver(self)
    }
    // ํ…Œ์ŠคํŠธ ์‹œ์ž‘ ์ „์—
    optional public func testBundleWillStart(_ testBundle: AnyObject!)
    
    // suite ์‹œ์ž‘ ์ „์—
    optional public func testSuiteWillStart(_ testSuite: AnyObject!)
    
    //test case๋ฅผ run ์‹œ
    optional public func testCaseWillStart(_ testCase: AnyObject!)
    
    // test case ์ข…๋ฃŒ ์‹œ
    optional public func testCaseDidFinish(_ testCase: AnyObject!)
    
    // ๋ญ”๊ฐ€ ์ž˜๋ชป ๋์„ ๋•Œ
    optional public func testCase(_ testCase: AnyObject!, didFailWithDescription description: AnyObject!, inFile filePath: AnyObject!, atLine lineNumber: AnyObject!)
    
    // ํ…Œ์ŠคํŠธ ๋งˆ์ณค์„ ๋–„
    optional public func testSuiteDidFinish(_ testSuite: AnyObject!)
    
    // ์ž‘์—…์„ ๋” ์ฒ˜๋ฆฌ ํ•  ์ˆ˜ ์žˆ๋Š” ๋งˆ์ง€๋ง‰ ์ฝœ๋ฐฑ
    optional public func testBundleDidFinish(_ testBundle: AnyObject!)

Crash Log Gathering

Crashes during testing

  • Crash๋Š” ํ…Œ์ŠคํŠธ failure ๋˜๋Š” ๋นˆ๋ฒˆํ•œ ์›์ธ์ด๋‹ค.
  • test host application, target application ๋ชจ๋‘ crash ๊ฐ€ ๋‚  ์ˆ˜ ์žˆ๋‹ค
  • Xcode๋Š” ๋ณดํ†ต test suite์„ ์™„์„ฑ์‹œํ‚ค๊ธฐ ์œ„ํ•ด์„œ host application์„ relaunch ํ•  ๊ฑฐ๋‹ค

๐Ÿ†• Crash Log Gathering

Xcode๊ฐ€ test report์— crash log๋“ค์„ ๋ชจ์•„์„œ ์ค„๊ฒƒ์ด์•ผ

UI, Unit tests ๋‘˜ ๋‹ค . local , Xcode Server ๋‘˜๋‹ค.

Xcode Server

Issue Tracking and Blame

์‚ฌ๋žŒ์€ ์™„๋ฒฝํ•˜์ง€ ์•Š์•„~ ์™„๋ฒฝํ•œ ์ฝ”๋“œ๋„ ์—†์–ด~ ๊ทธ๋ž˜์„œ Unit test๋ฅผ ํ•˜๋Š”๊ฑฐ์ง€.

๊ทธ๋ฆฌ๊ณ  ๊ฐ€๋” ๋นŒ๋“œ ์•ˆ๋˜๋Š” ์ฝ”๋“œ๋ฅผ ์ปค๋ฐ‹ ํ•˜์ง€~ ๊ทธ๋ž˜์„œ ์ด๋Ÿฐ ๊ฒฝ์šฐ์— Xcode๋Š” ์ด๋ฉ”์ผ์„ ๋ณด๋‚ด ์ค„๊ฑฐ์•ผ ๋„ˆ๊ฐ€ ์ฝ”๋“œ๋ฅผ brokeํ–ˆ๋‹ค๊ณ  ์•Œ๋ ค์ฃผ๋ ค๊ณ 

์ด๊ฑฐ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๋„ˆ๊ฐ€ ์™„๋ฒฝํ•œ ์ฝ”๋“œ๋ฅผ ์งฐ๋‹ค๊ณ  ํ•ด๋„, ๋„ˆ์˜ ์ฃผ๋ณ€์˜ ๊ฒƒ๋“ค์ด ๋ณ€ํ•  ์ˆ˜๊ฐ€ ์žˆ์ง€. ์˜ˆ๋ฅผ ๋“ค๋ฉด ์ƒˆ Xcode๋ฅผ ๋ฐ›์•˜์„ ๋•Œ, ์ƒˆ๋กœ์šด SDK๋ฅผ ๋ฐ›๊ณ  ์ƒˆ๋กœ์šด deprecation๋“ค์ด ์žˆ์„ ์ˆ˜ ์žˆ์–ด. ์–ธ์–ด์˜ improvement๋กœ ์ด์Šˆ๊ฐ€ ์ƒ๊ธธ ์ˆ˜ ๋„ ์žˆ์ง€. ๊ทธ๋Ÿฐ๋ฐ ๋ชจ๋“  Xcode๋Š” ๊ทธ ์ „ ๊บผ ๋ณด๋‹ค smartํ•ด. ๊ทธ๋ž˜์„œ ๊ทธ์ „์— ์—†๋˜ ์ด์Šˆ๋ฅผ ๋ฐœ๊ฒฌ ํ•  ์ˆ˜ ๋„ ์žˆ์–ด Xcode๊ฐ€ ์ถ”์  ํ•ด์ฃผ๊ธฐ ๋•Œ๋ฌธ์ด์ง€