コードカバレッジを⾒つつユニットテストを書く

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

 コードカバレッジを⾒つつユニットテストを書く

Tomoya Miwa

March 18, 2019

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

36 slides
  1. About me tomoya0x00 Twitter, GitHub, Qiita Android, Embedded system, BLE/BT,

    iOS DeNA Co., Ltd. Automotive Business Unit. 前回(Otemachi.apk #01)は⾵邪で登壇できなかった
  2. 既存コード fun hoge(x: Int): String { if (x >= 3)

    return "many" if (x == 2) return "two" if (x == 1) return "one" if (x == 0) return "zero" return "other" }
  3. テストコードを⾜す @Test fun hogeTest() { assert(hoge(3) == "many") assert(hoge(2) ==

    "two") assert(hoge(1) == "one") assert(hoge(0) == "zero") assert(hoge(-1) == "other") // ★追加テストコード }
  4. Kotlinっぽくしてみる fun hoge(x: Int): String = when { x >=

    3 -> "many" x == 2 -> "two" x == 1 -> "one" x == 0 -> "zero" else -> "other" }

More Decks by Tomoya Miwa

Other Decks in Programming