sbt / sbt-testng

Implementation of the sbt testing interface for TestNG, bundled with an sbt plug-in for convenience.
Other
9 stars 15 forks source link

not able to run integration tests through sbt testng interface #10

Open Harikiranvuyyuru opened 8 years ago

Harikiranvuyyuru commented 8 years ago

I want to run the integration tests located at path src/it/java using sbt task : sbt it:test

I have provided the following settings in my build.sbt :

Defaults.itSettings

javaSource in IntegrationTest := baseDirectory.value / "src/it/java"

testNGSettings

testNGSuites := Seq("src/it/resources/testng.xml")

Integration tests are not executed when I run the sbt task: it:test

Is there a way to run integration tests located in src/it through this plugin?

vuspenskiy commented 7 years ago

It is because test is hardcoded in testNGSettings, try expanding testNGSettings to its source (https://github.com/sbt/sbt-testng/blob/094f749250b4b18c613e7d7ce801c4b8abc567e0/plugin/src/main/scala/de/johoop/testngplugin/TestNGPlugin.scala) and fix scopes:

  .settings(
    resolvers += Resolver.sbtPluginRepo("releases"), // why is that necessary, and why like that?
    testNGVersion := testNGV,
    testNGOutputDirectory := ((crossTarget).value / "testng").absolutePath,
    testNGParameters := Seq(),
    testNGSuites := Seq(((resourceDirectory in IntegrationTest).value / "testng.yaml").absolutePath),
    libraryDependencies ++= Seq(
      "org.testng" % "testng" % (testNGVersion).value % "test,it",
      "org.yaml" % "snakeyaml" % "1.17" % "test,it",
      "de.johoop" %% "sbt-testng-interface" % "3.0.3" % "test,it"),
    testFrameworks += TestNGFrameworkID,
    testOptions += Tests.Argument(
      TestNGFrameworkID, ("-d" +:
        (testNGOutputDirectory).value +: (testNGParameters).value) ++
        (testNGSuites).value :_*
    )
  )