jeudi 3 décembre 2015

SBT "test" command runs object with main method

I have a bunch of unit tests, which I run with sbt test command. Also, I have a simulation tool (called FooSimulation), which I wrote myself and it's also in test directory. Running FooSimulation will produce foo.csv file, which has some data in it.

object FooSimulation extends App { ... }

As I can see now, when I've created the tool, running sbt test command also runs the tool, as foo.csv files are appearing. However I don't see any logging from the simulation tool in the test log (ok, that's might be because of some logging configuration).

So I made a search by the log for FooSimulation and didn't find anything, like it wasn't launched. I thought it's good idea to filter out this Simulation tool from the test package, using configuration: testOptions in Test := Seq(Tests.Filter(simulationFilter))

def simulationFilter(name: String): Boolean = !(name endsWith "Simulation")

Unfortunately, that didn't help as well.

So is there away to avoid running main/App objects in tests? Or the only way of doing it is to extract the simulation to src folder?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire