Ammonite is an interactive REPL for Scala, kind of like ipython is for Python.
I usually use IntelliJ IDE for Scala (which has a REPL and debugger among other things). Ammonite is great replacement though, when I don’t want to start up full blown IDE.
It’s really easy to get started with Ammonite. First it needs to be added to
built.sbt file as a library dependency via:
Warning: You may need to use an older version of ammonite based on your set up. I found 1.0.5 works better for some of my projects.
Warning 2: Make sure to remove “test” from version in build.sbt, if you are going to run it outside of test environment.
Once there, I just need to add the following lines of code to my file that I am trying to test:
For example running a test for my test class above, via:
sbt "testOnly com.alexkras.AmmoniteTestClass"Code language: CSS (css)
Will start the interactive REPL, where
myTestValue will get exposed as a variable named
test, allowing me to explore how test can be used.