Class

org.scalatestplus.junit

JUnit3Suite

Related Doc: package junit

Permalink

class JUnit3Suite extends TestCase with Suite with AssertionsForJUnit

A Suite that is also a junit.framework.TestCase.

A JUnit3Suite may be run by either JUnit 3 (such as JUnit 3.8) or ScalaTest's runner. You write it the way you write a JUnit 3 TestCase. Tests are methods that start with test, take no parameters, and have a Unit return type. You manage fixtures with methods setUp and tearDown. 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 from AssertionsForJUnit.

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 the Unit result type, like this:

def testGoodIdea(): Unit = { // result type will be Unit
  // ...
}

Instead of this:

def testBadIdea() = { // result type will be inferred
  // ...
}

If the testBadIdea method ends in an expression that has a result type other than Unit, the Scala compiler will infer a result type to the testBadIdea method to be the same non-Unit type. As a "result," JUnit 3 will not discover or run the testBadIdea method at all.

Self Type
JUnit3Suite
Linear Supertypes
AssertionsForJUnit, Suite, Serializable, Serializable, Assertions, TripleEquals, TripleEqualsSupport, TestCase, Test, Assert, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. JUnit3Suite
  2. AssertionsForJUnit
  3. Suite
  4. Serializable
  5. Serializable
  6. Assertions
  7. TripleEquals
  8. TripleEqualsSupport
  9. TestCase
  10. Test
  11. Assert
  12. AnyRef
  13. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new JUnit3Suite()

    Permalink

Type Members

  1. class CheckingEqualizer[L] extends AnyRef

    Permalink
    Definition Classes
    TripleEqualsSupport
  2. class Equalizer[L] extends AnyRef

    Permalink
    Definition Classes
    TripleEqualsSupport

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. def !==[T](right: Spread[T]): TripleEqualsInvocationOnSpread[T]

    Permalink
    Definition Classes
    TripleEqualsSupport
  3. def !==(right: Null): TripleEqualsInvocation[Null]

    Permalink
    Definition Classes
    TripleEqualsSupport
  4. def !==[T](right: T): TripleEqualsInvocation[T]

    Permalink
    Definition Classes
    TripleEqualsSupport
  5. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  6. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  7. def ===[T](right: Spread[T]): TripleEqualsInvocationOnSpread[T]

    Permalink
    Definition Classes
    TripleEqualsSupport
  8. def ===(right: Null): TripleEqualsInvocation[Null]

    Permalink
    Definition Classes
    TripleEqualsSupport
  9. def ===[T](right: T): TripleEqualsInvocation[T]

    Permalink
    Definition Classes
    TripleEqualsSupport
  10. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  11. macro def assert(condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    AssertionsForJUnit → Assertions
  12. macro def assert(condition: Boolean)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    AssertionsForJUnit → Assertions
  13. macro def assertCompiles(code: String)(implicit pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  14. macro def assertDoesNotCompile(code: String)(implicit pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  15. def assertResult(expected: Any)(actual: Any)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  16. def assertResult(expected: Any, clue: Any)(actual: Any)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  17. def assertThrows[T <: AnyRef](f: ⇒ Any)(implicit classTag: ClassTag[T], pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  18. macro def assertTypeError(code: String)(implicit pos: Position): Assertion

    Permalink
    Definition Classes
    Assertions
  19. macro def assume(condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    AssertionsForJUnit → Assertions
  20. macro def assume(condition: Boolean)(implicit prettifier: Prettifier, pos: Position): Assertion

    Permalink
    Definition Classes
    AssertionsForJUnit → Assertions
  21. def cancel(cause: Throwable)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  22. def cancel(message: String, cause: Throwable)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  23. def cancel(message: String)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  24. def cancel()(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  25. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. def conversionCheckedConstraint[A, B](implicit equivalenceOfA: Equivalence[A], cnv: (B) ⇒ A): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  27. def convertEquivalenceToAToBConstraint[A, B](equivalenceOfB: Equivalence[B])(implicit ev: <:<[A, B]): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  28. def convertEquivalenceToAToBConversionConstraint[A, B](equivalenceOfB: Equivalence[B])(implicit ev: (A) ⇒ B): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  29. def convertEquivalenceToBToAConstraint[A, B](equivalenceOfA: Equivalence[A])(implicit ev: <:<[B, A]): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  30. def convertEquivalenceToBToAConversionConstraint[A, B](equivalenceOfA: Equivalence[A])(implicit ev: (B) ⇒ A): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  31. def convertToCheckingEqualizer[T](left: T): CheckingEqualizer[T]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  32. implicit def convertToEqualizer[T](left: T): Equalizer[T]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  33. def countTestCases(): Int

    Permalink
    Definition Classes
    TestCase → Test
  34. def createResult(): TestResult

    Permalink
    Attributes
    protected[junit.framework]
    Definition Classes
    TestCase
  35. def defaultEquality[A]: Equality[A]

    Permalink
    Definition Classes
    TripleEqualsSupport
  36. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  37. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  38. final def execute(testName: String, configMap: ConfigMap, color: Boolean, durations: Boolean, shortstacks: Boolean, fullstacks: Boolean, stats: Boolean): Unit

    Permalink
    Definition Classes
    Suite
  39. def expectedTestCount(filter: Filter): Int

    Permalink

    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.

    Definition Classes
    JUnit3Suite → Suite
  40. def fail(cause: Throwable)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  41. def fail(message: String, cause: Throwable)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  42. def fail(message: String)(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  43. def fail()(implicit pos: Position): Nothing

    Permalink
    Definition Classes
    Assertions
  44. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  45. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  46. def getName(): String

    Permalink
    Definition Classes
    TestCase
  47. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  48. def intercept[T <: AnyRef](f: ⇒ Any)(implicit classTag: ClassTag[T], pos: Position): T

    Permalink
    Definition Classes
    Assertions
  49. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  50. def lowPriorityConversionCheckedConstraint[A, B](implicit equivalenceOfB: Equivalence[B], cnv: (A) ⇒ B): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  51. def lowPriorityTypeCheckedConstraint[A, B](implicit equivalenceOfB: Equivalence[B], ev: <:<[A, B]): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  52. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  53. def nestedSuites: IndexedSeq[Suite]

    Permalink
    Definition Classes
    Suite
  54. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  55. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  56. def pending: Assertion with PendingStatement

    Permalink
    Definition Classes
    Assertions
  57. def pendingUntilFixed(f: ⇒ Unit)(implicit pos: Position): Assertion with PendingStatement

    Permalink
    Definition Classes
    Assertions
  58. def rerunner: Option[String]

    Permalink
    Definition Classes
    Suite
  59. def run(testName: Option[String], args: Args): Status

    Permalink

    Overrides to use JUnit 3 to run the test(s).

    Overrides to use JUnit 3 to run the test(s).

    testName

    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.

    args

    the Args for this run

    returns

    a Status object that indicates when all tests and nested suites started by this method have completed, and whether or not a failure occurred.

    Definition Classes
    JUnit3Suite → Suite
  60. def run(arg0: TestResult): Unit

    Permalink
    Definition Classes
    TestCase → Test
  61. def run(): TestResult

    Permalink
    Definition Classes
    TestCase
  62. def runBare(): Unit

    Permalink
    Definition Classes
    TestCase
    Annotations
    @throws( classOf[java.lang.Throwable] )
  63. final def runNestedSuites(args: Args): Status

    Permalink

    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.

    args

    the Args for this run

    Attributes
    protected
    Definition Classes
    JUnit3Suite → Suite
    Exceptions thrown

    UnsupportedOperationException always.

  64. final def runTest(testName: String, args: Args): Status

    Permalink

    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.

    testName

    the name of one test to run.

    args

    the Args for this run

    Attributes
    protected
    Definition Classes
    JUnit3Suite → Suite
    Exceptions thrown

    UnsupportedOperationException always.

  65. def runTest(): Unit

    Permalink
    Attributes
    protected[junit.framework]
    Definition Classes
    TestCase
    Annotations
    @throws( classOf[java.lang.Throwable] )
  66. final def runTests(testName: Option[String], args: Args): Status

    Permalink

    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.

    testName

    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.

    args

    the Args for this run

    Attributes
    protected
    Definition Classes
    JUnit3Suite → Suite
    Exceptions thrown

    UnsupportedOperationException always.

  67. def setName(arg0: String): Unit

    Permalink
    Definition Classes
    TestCase
  68. def setUp(): Unit

    Permalink
    Attributes
    protected[junit.framework]
    Definition Classes
    TestCase
    Annotations
    @throws( classOf[java.lang.Exception] )
  69. final val styleName: String

    Permalink

    Suite style name.

    Suite style name.

    returns

    JUnit3Suite

    Definition Classes
    JUnit3Suite → Suite
  70. final val succeed: Assertion

    Permalink
    Definition Classes
    Assertions
  71. def suiteId: String

    Permalink
    Definition Classes
    Suite
  72. def suiteName: String

    Permalink
    Definition Classes
    Suite
  73. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  74. def tags: Map[String, Nothing]

    Permalink

    Returns an empty Map, because tags are not supported by JUnit 3.

    Returns an empty Map, because tags are not supported by JUnit 3.

    Definition Classes
    JUnit3Suite → Suite
  75. def tearDown(): Unit

    Permalink
    Attributes
    protected[junit.framework]
    Definition Classes
    TestCase
    Annotations
    @throws( classOf[java.lang.Exception] )
  76. final def testDataFor(testName: String, theConfigMap: ConfigMap = ConfigMap.empty): TestData

    Permalink
    Definition Classes
    JUnit3Suite → Suite
  77. def testNames: Set[String]

    Permalink

    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.

    Definition Classes
    JUnit3Suite → Suite
  78. def toExceptionFunction(message: Option[String]): (StackDepthException) ⇒ Option[String]

    Permalink

    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.

    Definition Classes
    AssertionsForJUnit
  79. def toString(): String

    Permalink
    Definition Classes
    TestCase → AnyRef → Any
  80. def typeCheckedConstraint[A, B](implicit equivalenceOfA: Equivalence[A], ev: <:<[B, A]): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  81. implicit def unconstrainedEquality[A, B](implicit equalityOfA: Equality[A]): CanEqual[A, B]

    Permalink
    Definition Classes
    TripleEquals → TripleEqualsSupport
  82. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  83. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  84. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  85. def withClue[T](clue: Any)(fun: ⇒ T): T

    Permalink
    Definition Classes
    Assertions

Deprecated Value Members

  1. final def execute: Unit

    Permalink
    Definition Classes
    Suite
    Annotations
    @deprecated
    Deprecated

    The parameterless execute method has been deprecated and will be removed in a future version of ScalaTest. Please invoke execute with empty parens instead: execute().

  2. def trap[T](f: ⇒ T): Throwable

    Permalink
    Definition Classes
    Assertions
    Annotations
    @deprecated
    Deprecated

    The trap method is no longer needed for demos in the REPL, which now abreviates stack traces, and will be removed in a future version of ScalaTest

Inherited from AssertionsForJUnit

Inherited from Suite

Inherited from Serializable

Inherited from Serializable

Inherited from Assertions

Inherited from TripleEquals

Inherited from TripleEqualsSupport

Inherited from TestCase

Inherited from Test

Inherited from Assert

Inherited from AnyRef

Inherited from Any

Ungrouped