trait AssertionsForJUnit extends VersionSpecificAssertionsForJUnit
Trait that contains ScalaTest's basic assertion methods, suitable for use with JUnit.
The assertion methods provided in this trait look and behave exactly like the ones in
Assertions
, except instead of throwing
TestFailedException
they throw
JUnitTestFailedError
,
which extends junit.framework.AssertionFailedError
.
JUnit 3 (release 3.8 and earlier) distinguishes between failures and errors.
If a test fails because of a failed assertion, that is considered a failure. If a test
fails for any other reason, either the test code or the application being tested threw an unexpected
exception, that is considered an error. The way JUnit 3 decides whether an exception represents
a failure or error is that only thrown junit.framework.AssertionFailedError
s are considered
failures. Any other exception type is considered an error. The exception type thrown by the JUnit 3
assertion methods declared in junit.framework.Assert
(such as assertEquals
,
assertTrue
, and fail
) is, therefore, AssertionFailedError
.
In JUnit 4, AssertionFailedError
was made to extend java.lang.AssertionError
,
and the distinction between failures and errors was essentially dropped. However, some tools that integrate
with JUnit carry on this distinction, so even if you are using JUnit 4 you may want to use this
AssertionsForJUnit
trait instead of plain-old ScalaTest
Assertions
.
To use this trait in a JUnit 3 TestCase
, you can mix it into your TestCase
class, like this:
import junit.framework.TestCase import org.scalatest.junit.AssertionsForJUnit
class MyTestCase extends TestCase with AssertionsForJUnit {
def testSomething() { assert("hi".charAt(1) === 'i') }
// ... }
You can alternatively import the methods defined in this trait.
import junit.framework.TestCase import org.scalatest.junit.AssertionsForJUnit._
class MyTestCase extends TestCase {
def testSomething() { assert("hi".charAt(1) === 'i') }
// ... }
For details on the importing approach, see the documentation
for the AssertionsForJUnit
companion object.
For the details on the AssertionsForJUnit
syntax, see the Scaladoc documentation for
org.scalatest.Assertions
- Alphabetic
- By Inheritance
- AssertionsForJUnit
- VersionSpecificAssertionsForJUnit
- Assertions
- TripleEquals
- TripleEqualsSupport
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
!==[T](right: Spread[T]): TripleEqualsInvocationOnSpread[T]
- Definition Classes
- TripleEqualsSupport
-
def
!==(right: Null): TripleEqualsInvocation[Null]
- Definition Classes
- TripleEqualsSupport
-
def
!==[T](right: T): TripleEqualsInvocation[T]
- Definition Classes
- TripleEqualsSupport
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
===[T](right: Spread[T]): TripleEqualsInvocationOnSpread[T]
- Definition Classes
- TripleEqualsSupport
-
def
===(right: Null): TripleEqualsInvocation[Null]
- Definition Classes
- TripleEqualsSupport
-
def
===[T](right: T): TripleEqualsInvocation[T]
- Definition Classes
- TripleEqualsSupport
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
macro
def
assert(condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: Position): Assertion
- Definition Classes
- VersionSpecificAssertionsForJUnit → Assertions
-
macro
def
assert(condition: Boolean)(implicit prettifier: Prettifier, pos: Position): Assertion
- Definition Classes
- VersionSpecificAssertionsForJUnit → Assertions
-
macro
def
assertCompiles(code: String)(implicit pos: Position): Assertion
- Definition Classes
- Assertions
-
macro
def
assertDoesNotCompile(code: String)(implicit pos: Position): Assertion
- Definition Classes
- Assertions
-
def
assertResult(expected: Any)(actual: Any)(implicit prettifier: Prettifier, pos: Position): Assertion
- Definition Classes
- Assertions
-
def
assertResult(expected: Any, clue: Any)(actual: Any)(implicit prettifier: Prettifier, pos: Position): Assertion
- Definition Classes
- Assertions
-
def
assertThrows[T <: AnyRef](f: ⇒ Any)(implicit classTag: ClassTag[T], pos: Position): Assertion
- Definition Classes
- Assertions
-
macro
def
assertTypeError(code: String)(implicit pos: Position): Assertion
- Definition Classes
- Assertions
-
macro
def
assume(condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: Position): Assertion
- Definition Classes
- VersionSpecificAssertionsForJUnit → Assertions
-
macro
def
assume(condition: Boolean)(implicit prettifier: Prettifier, pos: Position): Assertion
- Definition Classes
- VersionSpecificAssertionsForJUnit → Assertions
-
def
cancel(cause: Throwable)(implicit pos: Position): Nothing
- Definition Classes
- Assertions
-
def
cancel(message: String, cause: Throwable)(implicit pos: Position): Nothing
- Definition Classes
- Assertions
-
def
cancel(message: String)(implicit pos: Position): Nothing
- Definition Classes
- Assertions
-
def
cancel()(implicit pos: Position): Nothing
- Definition Classes
- Assertions
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
convertEquivalenceToAToBConstraint[A, B](equivalenceOfB: Equivalence[B])(implicit ev: <:<[A, B]): CanEqual[A, B]
- Definition Classes
- TripleEquals → TripleEqualsSupport
-
def
convertEquivalenceToBToAConstraint[A, B](equivalenceOfA: Equivalence[A])(implicit ev: <:<[B, A]): CanEqual[A, B]
- Definition Classes
- TripleEquals → TripleEqualsSupport
-
def
convertToCheckingEqualizer[T](left: T): CheckingEqualizer[T]
- Definition Classes
- TripleEquals → TripleEqualsSupport
-
implicit
def
convertToEqualizer[T](left: T): Equalizer[T]
- Definition Classes
- TripleEquals → TripleEqualsSupport
-
def
defaultEquality[A]: Equality[A]
- Definition Classes
- TripleEqualsSupport
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
fail(cause: Throwable)(implicit pos: Position): Nothing
- Definition Classes
- Assertions
-
def
fail(message: String, cause: Throwable)(implicit pos: Position): Nothing
- Definition Classes
- Assertions
-
def
fail(message: String)(implicit pos: Position): Nothing
- Definition Classes
- Assertions
-
def
fail()(implicit pos: Position): Nothing
- Definition Classes
- Assertions
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
intercept[T <: AnyRef](f: ⇒ Any)(implicit classTag: ClassTag[T], pos: Position): T
- Definition Classes
- Assertions
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
lowPriorityTypeCheckedConstraint[A, B](implicit equivalenceOfB: Equivalence[B], ev: <:<[A, B]): CanEqual[A, B]
- Definition Classes
- TripleEquals → TripleEqualsSupport
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
pending: Assertion with PendingStatement
- Definition Classes
- Assertions
-
def
pendingUntilFixed(f: ⇒ Unit)(implicit pos: Position): Assertion with PendingStatement
- Definition Classes
- Assertions
-
final
val
succeed: Assertion
- Definition Classes
- Assertions
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toExceptionFunction(message: Option[String]): (StackDepthException) ⇒ Option[String]
If message or message contents are null, throw a null exception, otherwise create a function that returns the option.
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
typeCheckedConstraint[A, B](implicit equivalenceOfA: Equivalence[A], ev: <:<[B, A]): CanEqual[A, B]
- Definition Classes
- TripleEquals → TripleEqualsSupport
-
implicit
def
unconstrainedEquality[A, B](implicit equalityOfA: Equality[A]): CanEqual[A, B]
- Definition Classes
- TripleEquals → TripleEqualsSupport
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
withClue[T](clue: Any)(fun: ⇒ T): T
- Definition Classes
- Assertions
Deprecated Value Members
-
def
conversionCheckedConstraint[A, B](implicit equivalenceOfA: Equivalence[A], cnv: (B) ⇒ A): CanEqual[A, B]
- Definition Classes
- TripleEquals → TripleEqualsSupport
- Annotations
- @deprecated
- Deprecated
(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.
-
def
convertEquivalenceToAToBConversionConstraint[A, B](equivalenceOfB: Equivalence[B])(implicit ev: (A) ⇒ B): CanEqual[A, B]
- Definition Classes
- TripleEquals → TripleEqualsSupport
- Annotations
- @deprecated
- Deprecated
(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.
-
def
convertEquivalenceToBToAConversionConstraint[A, B](equivalenceOfA: Equivalence[A])(implicit ev: (B) ⇒ A): CanEqual[A, B]
- Definition Classes
- TripleEquals → TripleEqualsSupport
- Annotations
- @deprecated
- Deprecated
(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.
-
def
lowPriorityConversionCheckedConstraint[A, B](implicit equivalenceOfB: Equivalence[B], cnv: (A) ⇒ B): CanEqual[A, B]
- Definition Classes
- TripleEquals → TripleEqualsSupport
- Annotations
- @deprecated
- Deprecated
(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.