The Artima Developer Community
Sponsored Link

ScalaTest/ScalaUtils Forum
SUnit vs. ScalaTest

1 reply on 1 page. Most recent reply: Jan 23, 2008 6:57 PM by Bill Venners

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Paul LaCrosse

Posts: 1
Nickname: pjlacrosse
Registered: Dec, 2007

SUnit vs. ScalaTest Posted: Jan 23, 2008 12:48 PM
Reply to this message Reply
Advertisement
For someone not familiar with the included Scala SUnit test package, or with your ScalaTest packaqe, what would you say are the highlights of a comparison between them?


Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: SUnit vs. ScalaTest Posted: Jan 23, 2008 6:57 PM
Reply to this message Reply
> For someone not familiar with the included Scala SUnit
> test package, or with your ScalaTest packaqe, what would
> you say are the highlights of a comparison between them?
>
They are quite different.

SUnit was an early port of the basic types of JUnit to Scala. It doesn't really do much besides those basic types, and the port does not go very far in taking advantage of Scala. It also doesn't have much of a runner. If you mix in a TestConsoleMain trait, you get this code:


val r = new TestResult()
suite.run(r)
for (val tf <- r.failures()) {
println(tf.toString())


That's the extent of SUnit's runner. I was a bit disappointed to see that many of what I consider JUnit 3's blemishes were repeated in SUnit. In a trait named Assert, which is a verb, they have the same assertTrue, assertFalse, assertEquals methods that JUnit has, and the ones that take a string message have it first not second. So it is very more a transliteration than a translation of JUnit's basic types to Scala.

By contrast, although ScalaTest also comes from a Java unit test framework, SuiteRunner, ScalaTest was very much redesigned to take advantage of Scala. For example, you specify assertions like this:


assert(!s.contains("L"))
assert(t === "Hi")
expect(9) {
sqrt(81)
}
intercept(classOf[StringIndexOutOfBoundsException]) {
s.charAt(-1)
}


It also has a very capable runner whose features rival those of JUnit 4 and TestNG. With ScalaTest's Runner you can execute tests concurrently if you want, specify groups of tests to include or exclude (placing test methods into groups using annotations), mark tests as Ignored with an annotation, specify packages in which to discover Suites automatically so you can write new Suites of tests and push a button to have them discovered and run. You can send reports of test results to the standard output, standard error, into files, or into a GUI.

ScalaTest is also very extensible. If you don't like the defaults, you can change them by overriding methods. One of the things I have planned for the next few months, for example, is creating Suite sub-traits that allow you to write tests that will run both as ScalaTest Suites or JUnit 3/TestNG/JUnit 4 tests.

ScalaTest's GUI is quite nice, and its documentation is thorough. It is in beta now, because all its 1.0 features are in place. It is a full-featured testing tool written in Scala that is ready for production use. The best place to find out more about is it reading the scaladoc documentation for Suite:

http://www.artima.com/scalatest/doc-0.9.1/org/scalatest/Suite.html

After that, try the scaladoc documentation for Runner:

http://www.artima.com/scalatest/doc-0.9.1/org/scalatest/Runner$object.html

Flat View: This topic has 1 reply on 1 page
Topic: space a separator for runpath Previous Topic   Next Topic Topic: provide a RunnerJPanel

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use