Friday, August 7, 2015

Some tips and tricks when doing TDD with SBT (and Play Framework)

If you are doing any TDD with SBT or Play Framework, here are a few tips and tricks to make you happy.
  1. Choose the right command tool to run your tests: 
    •  test       - runs all tests.
    •  testOnly   - runs only one test (e.g. testOnly test1) or wild card specific tests (e.g. testOnly test1*).
    •  testQuick  - runs only the tests that haven't run yet or failed ones. Can be limited to a specific test scope with a wild card (e.g. testQuick test1*).
  2. Since you are going run these command many many times, add the following shortcuts in build.sbt:
    •  to  for testOnly - addCommandAlias("to", "testOnly")
    •  tq  for testQuick - addCommandAlias("tq", "testQuick")
  3. Divide your tests into groups/folders. E.g., have a folder for unit tests in folder "unit" and run those test with  to unit.* .


No comments:

Post a Comment