37

I have an SBT 0.7.5 project and its some test cases fail. Until all test cases are fixed, I want to skip tests to generate a JAR. Is there any command line argument that tells SBT to skip all tests, like Maven's -Dmaven.test.skip=true flag?

Roman Nikitchenko
  • 12,800
  • 7
  • 74
  • 110
trustin
  • 12,231
  • 6
  • 42
  • 52

2 Answers2

114

I had the same problem, I'm using the assembly plugin. In this case, the solution was to modify the build file and add

test in assembly := {}
OlliM
  • 7,023
  • 1
  • 36
  • 47
  • 3
    This should be the marked as the proper answer, cos it tells you how ``test`` can be made to do nothing in a certain scope. – Richard Gomes Nov 03 '15 at 11:37
  • 3
    This changes the build file though, which isn't how I would want to skip tests - the maven command line flag is a more useful version, but it appears there is no (sbt-) run-time option to skip tests. – Rick Moritz Apr 06 '17 at 07:00
  • Indeed, this can also be done at-runtime-only using the `set` keyword of sbt, like `sbt 'set test in assembly := {}' clean assembly`. See [kshakir's answer](https://stackoverflow.com/a/31737303/1885518) from [How run sbt assembly command without tests from command line?](https://stackoverflow.com/questions/26499444/how-run-sbt-assembly-command-without-tests-from-command-line/) – Murmel Apr 16 '18 at 17:24
  • Hi, when I add this to build.sbt I get the error: error: not found: value assembly running sbt assembly words just fine. – Dalton Sweeney Apr 07 '20 at 19:44
9

Instead of using compile, you could use package. The compile tasks also runs the tests, package doesn't.

myborobudur
  • 4,385
  • 8
  • 40
  • 61
  • 2
    what does this answer mean? Example? – user239558 Dec 02 '14 at 11:54
  • 6
    Despite it works in several circumstances, this answer does not really answer the question. A proper answer should say how you can disable tests in a certain scope, instead of directing you to employ another task, instead of ``test``. – Richard Gomes Nov 03 '15 at 11:36