fedragon
fedragon

Reputation: 884

sbt-assembly: skip specific test

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.

Upvotes: 6

Views: 4998

Answers (4)

JR Utily
JR Utily

Reputation: 1852

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
      )

Upvotes: 0

Mark Butler
Mark Butler

Reputation: 4391

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 := {})

Upvotes: 1

Eugene Yokota
Eugene Yokota

Reputation: 95654

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

Upvotes: 6

laughedelic
laughedelic

Reputation: 6460

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 := { ... }

Upvotes: 0

Related Questions