Inspiration

When write unit test, easy to forget unhappy path. so, generate test case placeholder with unhappy-path, reduce mistake boundary check.

Unit Testを書いてもHappy-pathのみになることが多いので、un-happy-pathのテストを忘れないように雛形で強制するためのコードジェネレータを作りましょう。 主に境界値テストの手助けです。

What it does

Input

class Sparrow {
   func fly(to_km: Int) {
   }

   func eat(energy: Meal) -> Bool {
      // return true if enable eat
   }
}

Output (Test code)

class SparrowTest {
   func testFly() {}
   func testFlyWithMaximam() {}
   func testFlyWIthValueOutOfBounds() {}

   func testEatWithMealInsect() {}
   func testEatWithMealMeat() {}
}

How I built it

as Xcode plugin

usecase

  • create new file.
  • write class and method definitions.
  • select menu > edit > generate unit test.
  • then, add new file if need.
  • then, add method test template, that include test for covering famous mistake.

Challenges I ran into

Before developers end up their activity, give a chance to acknowledge famous mistake.

Accomplishments that I'm proud of

What I learned

What's next for Unit Test Assistant

  • This version does not have enough variation. so, we'll add assist code for fame failures.
  • Detecting syntax is not well, so we try SourceKit to use SyntaxTree.
    • currently, expected source code should be well formatted.

Built With

Share this project:

Updates