This fork adds unit tests to the exercises. It is still under development, the unit tests have been added up to the chapter 7 so far.
The modifications to the original repository have been kept to minimal but in some cases the solution or the exercise statement may be slightly different to be testable. For example, for some exercises the method signatures were added. If for one exercise in the book the method signature is not present you may want to guess it before jumping to the code!
The new sub-module 'tests' contains, who would have guessed, the unit tests.
> git clone https://github.com/RheinMainScala/fpinscala.git
> cd fpinscala
> sbt eclipse
In eclipse import the existing projects (Import... / General-Existing Projects into Workspace). Tick the option "Search for nested projects" and add at least the projects 'exercises' and 'tests'.
The project 'tests' contains the unit tests to run against your code in 'exercises'. Run them as "Scala JUnit Test". The tests use the library specs2 and especially a feature called Datatables.
> sbt
> ~testOnly <test class> // e.g. ~testOnly fpinscala.gettingstarted.GettingStartedSpec
// or ~testOnly *GettingStartedSpec (if there is only one GettingStartedSpec)
// You can choose the tests to run by specifying a regular expression:
> ~testOnly <test class> -- -ex "<regexp>" // e.g. testOnly *GettingStartedSpec -- -ex "Exercise 2.1"
Use your favorite editor to edit the exercise file. The test will run each time you save it.
By default, the tests are run against the module 'exercises', which doesn't contain any solution for this repository. If you want to modify or create new tests you can run them against the existing solutions by running :
> sbt -Dtest=answers
before launching the tests or creating the eclipse project.
The original readme can be found here.