I'm a completely newbie Scala programmer, and I have no previous experience with Java; I come from ruby. I'm trying to run my first TDD sample program. I'm planning something very small, with maybe 5 or 6 tests. I'm trying to use the specs2 lib. I have no IDE, I usually program with vim and execute stuff from the command line.
How do I work with scala & specs2 on my little .scala file from the command line?
In the Quick Start they mention this:
scala -cp ... specs2.run HelloWorldSpec
...
) is standing for. What do I have to put there?specs2.run
. But on the downloads section I only get a .jar file. Where is specs2.run
?Thanks a lot.
Welcome to scala and specs2!
The ...
stands for the paths to all the jars you need to run the specifications, including your own (or a path to a directory containing the .class
files). Those jars are listed on the Runners page. For a simple specification you only need scalaz-core, scalaz-concurrent and specs2.
specs2.run
is the full name of the class used to run your specification on the command line. So, a full command to run a specification looks like:
scala -cp scalaz-core.jar:scalaz-concurrent.jar:specs2.jar:your-classes-directory specs2.run YourSpecification
You can indeed use the command line only without sbt or maven if you know where to get the jars you need and how to compile your scala classes (using the scalac
command)
yes, the sample app comes with sbt and maven project files so that running the tests just takes sbt test
for example. If you do that, sbt installs all the required dependencies, compiles the classes and runs the tests. I think that this is the best way to get started (follow the sbt install guide, it's really fast IMHO) but again, for a simple project you can also do that manually
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With