sbt-assembly: skip specific test
Asked Answered
J

4

6

I would like to configure sbt-assembly to skip a specific test class.

Is there any way to do this? If it helps, I tagged the test using ScalaTest @Network tag.

Jennifferjennilee answered 18/3, 2014 at 13:42 Comment(0)
S
6

See Additional test configurations with shared sources. This allows you to come up with alternative "test" task in FunTest configuration while reusing your test source.

After you have fun:test working with whatever filter you define using testOptions in FunTest := Seq(Tests.Filter(itFilter)), you can then rewire

test in assembly := test in FunTest
Sadden answered 19/3, 2014 at 3:20 Comment(0)
C
1

Eugene is right (obviously) but that wasn't quite enough information for me to get it to work - I have a build.scala file. I am defining baseSettings like this:

     val baseSettings = Defaults.defaultSettings ++ 
                        buildSettings ++  
                        Seq(sbt.Keys.test in assembly := {})
Consentient answered 13/1, 2015 at 22:52 Comment(0)
G
0

You can tag your tests with ignore, then sbt/ScalaTest won't run them. See ScalaTest docs on Tagging tests.

Just for completeness, if you want to skip all tests in assembly task or run only particular ones you can customize it with test in assembly := { ... }

Glosso answered 18/3, 2014 at 16:50 Comment(2)
my question is precisely about skipping specific tests in sbt-assembly: let my test name be VerySlowTest, could you provide an example on how to configure sbt-assembly to ignore this test?Jennifferjennilee
In the solution, that I suggested you don't need to do anything with sbt-assembly, instead you can add the ignore tag to the test, in the definition of the test (see the link I gave to the ScalaTest docs). I can't just show you the code, because it depends on the way you define your test. Anyway, I think @eugene-yokota already suggested a better solution.Glosso
N
0

Based on @eugene-yokata reply, I found how to use the flag from ScalaTest:

lazy val UnitTest = config("unit") extend (Test)

lazy val companyApp = (project in file("applications/"))
      .assembly("com.company.app", "app.jar")
      .configs(UnitTest)
      .settings(
        inConfig(UnitTest)(Defaults.testTasks),
        UnitTest / testOptions ++= Seq(
          Tests.Argument(
            TestFrameworks.ScalaTest,
            "-l",
            "com.company.tag.HttpIntegrationTest"
          ),
          Tests.Argument(
            TestFrameworks.ScalaTest,
            "-l",
            "com.company.tag.EsIntegrationTest"
          )
        ),
        test in assembly := (UnitTest / test).value
      )
Niblick answered 25/6, 2020 at 9:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.