Returns the number of tests expected to be run by JUnit when run is invoked
on this Suite.
Returns the number of tests expected to be run by JUnit when run is invoked
on this Suite.
If tagsToInclude in the passed Filter is defined, this class's
implementation of this method returns 0. Else this class's implementation of this method
returns the size of the set returned by testNames on the current instance.
Overrides to use JUnit 3 to run the test(s).
Overrides to use JUnit 3 to run the test(s).
an optional name of one test to run. If None, all relevant tests should be run.
I.e., None acts like a wildcard that means run all relevant tests in this Suite.
the Args for this run
a Status object that indicates when all tests and nested suites started by this method have completed, and whether or not a failure occurred.
Throws UnsupportedOperationException, because this method is unused by this
class, given this class's run method delegates to JUnit to run
its tests.
Throws UnsupportedOperationException, because this method is unused by this
class, given this class's run method delegates to JUnit to run
its tests.
The main purpose of this method implementation is to render a compiler error an attempt
to mix in a trait that overrides runNestedSuites. Because this
trait does not actually use runNestedSuites, the attempt to mix
in behavior would very likely not work.
the Args for this run
UnsupportedOperationException always.
Throws UnsupportedOperationException, because this method is unused by this
class, given this class's run method delegates to JUnit to run
its tests.
Throws UnsupportedOperationException, because this method is unused by this
class, given this class's run method delegates to JUnit to run
its tests.
The main purpose of this method implementation is to render a compiler error an attempt
to mix in a trait that overrides runTest. Because this
trait does not actually use runTest, the attempt to mix
in behavior would very likely not work.
the name of one test to run.
the Args for this run
UnsupportedOperationException always.
Throws UnsupportedOperationException, because this method is unused by this
class, given this class's run method delegates to JUnit to run
its tests.
Throws UnsupportedOperationException, because this method is unused by this
class, given this class's run method delegates to JUnit to run
its tests.
The main purpose of this method implementation is to render a compiler error an attempt
to mix in a trait that overrides runTests. Because this
trait does not actually use runTests, the attempt to mix
in behavior would very likely not work.
an optional name of one test to run. If None, all relevant tests should be run.
I.e., None acts like a wildcard that means run all relevant tests in this Suite.
the Args for this run
UnsupportedOperationException always.
Suite style name.
Returns an empty Map, because tags are not supported by JUnit 3.
Returns an empty Map, because tags are not supported by JUnit 3.
Returns the set of test names that will be executed by JUnit when run is invoked
on an instance of this class, or the instance is passed directly to JUnit for running.
Returns the set of test names that will be executed by JUnit when run is invoked
on an instance of this class, or the instance is passed directly to JUnit for running.
The iterator obtained by invoking elements on this
returned Set will produce the test names in their natural order, as determined by String's
compareTo method. Nevertheless, this method is not consulted by JUnit when it
runs the tests, and JUnit may run the tests in any order.
If message or message contents are null, throw a null exception, otherwise create a function that returns the option.
If message or message contents are null, throw a null exception, otherwise create a function that returns the option.
(Since version 3.1.0) The conversionCheckedConstraint method has been deprecated and will be removed in a future version of ScalaTest. It is no longer needed now that the deprecation period of ConversionCheckedTripleEquals has expired. It will not be replaced.
(Since version 3.1.0) The convertEquivalenceToAToBConversionConstraint method has been deprecated and will be removed in a future version of ScalaTest. It is no longer needed now that the deprecation period of ConversionCheckedTripleEquals has expired. It will not be replaced.
(Since version 3.1.0) The convertEquivalenceToBToAConversionConstraint method has been deprecated and will be removed in a future version of ScalaTest. It is no longer needed now that the deprecation period of ConversionCheckedTripleEquals has expired. It will not be replaced.
(Since version 3.1.0) The lowPriorityConversionCheckedConstraint method has been deprecated and will be removed in a future version of ScalaTest. It is no longer needed now that the deprecation period of ConversionCheckedTripleEquals has expired. It will not be replaced.
A
Suitethat is also ajunit.framework.TestCase.A
JUnit3Suitemay be run by either JUnit 3 (such as JUnit 3.8) or ScalaTest's runner. You write it the way you write a JUnit 3TestCase. Tests are methods that start withtest, take no parameters, and have aUnitreturn type. You manage fixtures with methodssetUpandtearDown. Here's an example:import org.scalatest.junit.JUnit3Suite import scala.collection.mutable.ListBuffer class BlastFromThePastSuite extends JUnit3Suite { var sb: StringBuilder = _ var lb: ListBuffer[String] = _ override def setUp(): Unit = { sb = new StringBuilder("ScalaTest is ") lb = new ListBuffer[String] } def testEasy(): Unit = { // Uses JUnit-style assertions sb.append("easy!") assertEquals("ScalaTest is easy!", sb.toString) assertTrue(lb.isEmpty) lb += "sweet" } def testFun(): Unit = { // Uses ScalaTest assertions sb.append("fun!") assert(sb.toString === "ScalaTest is fun!") assert(lb.isEmpty) } }You can use either JUnit's assertions, inherited from
TestCase, or ScalaTest's, inherited fromAssertionsForJUnit.When writing JUnit 3 tests in Scala, you should keep in mind that JUnit 3 will not run tests that have a return type other than
Unit. Thus it is best to explicitly state theUnitresult type, like this:def testGoodIdea(): Unit = { // result type will be Unit // ... }Instead of this:
def testBadIdea() = { // result type will be inferred // ... }If the
testBadIdeamethod ends in an expression that has a result type other thanUnit, the Scala compiler will infer a result type to thetestBadIdeamethod to be the same non-Unittype. As a "result," JUnit 3 will not discover or run thetestBadIdeamethod at all.