Search code examples
scalaintellij-ideasbtscalatest

How to run tests on every code change in IntelliJ IDEA from Scala sbt project?


I have a new Scala/sbt project set up in IntelliJ IDEA with ScalaTest and jUnit interface successfully installed as dependencies. I have one test that passes when I hit run or debug.

My problem is that it doesn't rerun if I change something. I have to hit run or debug again and then it runs and gives the expected response.

How do I set up IntelliJ IDEA (with or without sbt) to run all tests every time the code changes? Is it possible to run the tests related to the files that were changed only?


Solution

  • As answered in comment by Boris the Spider you can run

    > ~test
    

    from sbt shell. Hopefully sbt and IntelliJ can integrate better via sbt server, but I don't think it's currently possible.