First, thanks Sean for such a nice answer about Maven. I will try and
capture that info on the user guide I'm polishing off, so there will
be a central place.
As to your question about TestNG, Erik, what Sean showed you was how
to run any style of ScalaTest suite or spec through Maven. It is done
by going through JUnit, which most tools understand. If you want to
write TestNG tests in Scala, you can do that, and ScalaTest also has
some integration, but those look like and actually are TestNG tests.
Thus you'd make test methods and put the @Test annotation on them.
Here's an example:
http://www.scalatest.org/scaladoc-1.6.1/#org.scalatest.testng.TestNGSuite
A TestNGSuite is both a ScalaTest Suite and a TestNG test class. They
can be run with either ScalaTest or TestNG. Because they actually are
TestNG test classes, you can run them with Maven however you are
running any other TestNG test classes written in Java or any other JVM
language. But if you want to do FunSuites or FeatureSpecs, etc., you'd
put on JUnitRunner and let Maven those run through JUnit.
Bill
> --
> You received this message because you are subscribed to the Google
> Groups "scalatest-users" group.
> To post to this group, send email to scalate...@googlegroups.com
> To unsubscribe from this group, send email to
> scalatest-use...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/scalatest-users?hl=en
> ScalaTest itself, and documentation, is available here:
> http://www.artima.com/scalatest
--
Bill Venners
Artima, Inc.
http://www.artima.com
On Wed, Jul 13, 2011 at 4:19 PM, Erik Peterson <coach...@gmail.com> wrote:
> Thank you gentlemen for your assistance. I'm still unable to get mvn and
> FunSuite working together. Here are my results with 3 cases.
>
> 1) Apparently Mixing TestNG and FunSuite is not supported, correct?
>
> @RunWith(classOf[JUnitRunner])
> class FunRunTest extends TestNGSuite with FunSuite {
> @Test def canaryTest: Unit = assert(true === true)
> test("Value is even") { assert(4 % 2 === 0)}
> }
>
> error: overriding method runTest in trait TestNGSuite of type (testName:
> String, reporter: org.scalatest.Reporter, stopper: org.scalatest.Stopper,
> configMap: Map[String,Any], tracker: org.scalatest.Tracker)Unit; .......
>
Correct. Those two aren't designed to stack, so they don't compile
when you attempt that. Reason is that TestNGSuite is also a TestNG
test class, and TestNG would have no idea what to do with test("...")
{ ... }.
> 2) The following works in intellij and from maven cli (mvn -Dtest=FunRunTest
> clean test):
>
> class FunRunTest extends TestNGSuite {
> @Test def canaryTest: Unit = assert(true === true)
> }
>
Yes, that's just using TestNGSuite.
> 3) The following works in intellij, but FAILS from maven cli (mvn
> -Dtest=FunRunTest clean test):
>
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-surefire-plugin:2.7.2:test (default-test) on
> project simple: No tests were executed! (Set -DfailIfNoTests=false to
> ignore this error.) -> [Help 1]
>
> //note that adding or removing this annotation has no impact on the test
> result, just doesn't find the test
> @RunWith(classOf[JUnitRunner])
> class FunRunTest extends FunSuite {
> test("Value is even") { assert(4 % 2 === 0)}
> }
>
> Note that I don't specify sourceDirectory or testSourceDirectory. This is a
> mixed project with scala and java and maven allows defining only one
> instance of each. But the Scala compiler handles compiling all *.scala and
> *.java files, so this hasn't been an issue so far.
>
Hmm. Code looks fine so maybe this is the issue. Somehow Maven needs
to discover your class. It does by default look for classes ending
with "Test" like you have. So it is probably that it isn't looking in
the correct directory. Does maven actually look for source files with
that name? Because I'd have figured they'd be rooting through the
class files.
Bill
Just to follow up that the training on ScalaTest went well except for this issue. Would really like to get this resolved before the next training. The use case is to add ScalaTest and its FunSuite trait to existing Java/maven projects. Seems that this would be a fairly common use case as existing Java shops evaluate Scala. Thanks again!
Thanks so much, Sean, for all your helpful answers. I'm at the
Scalathon documentation day right now, and will be working on the user
guide today. I'll try and get this in there so it is in a central
place.
Bill
> --
> You received this message because you are subscribed to the Google
> Groups "scalatest-users" group.
> To post to this group, send email to scalate...@googlegroups.com
> To unsubscribe from this group, send email to
> scalatest-use...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/scalatest-users?hl=en
> ScalaTest itself, and documentation, is available here:
> http://www.artima.com/scalatest
--