PureharmTest

abstract class PureharmTest extends FunSuite with PureharmAssertions with PureharmTestRuntimeLazyConversions

Base class that is recommended to be extended in a "testkit" module in your own application, and added the corresponding flavor.

Base class that is recommended to be extended in a "testkit" module in your own application, and added the corresponding flavor.

All tests are in IO[Unit], and no special syntax is offered to return any other types of values.

Authors
Since

24 Jun 2020

class FunSuite
trait ValueTransforms
trait SuiteTransforms
trait TestTransforms
trait TestOptionsConversions
trait FunFixtures
trait Assertions
trait CompileErrorMacro
class Suite
trait PlatformSuite
class Object
trait Matchable
class Any

Type members

Classlikes

class PureharmSyncIOOps[T](fixture: SyncIO[FunFixture[T]])

Inherited classlikes

abstract class Fixture[T](val fixtureName: String)
Value Params
name

The name of this fixture, used for displaying an error message if beforeAll() or afterAll() fail.

Inherited from
Suite
object FunFixture
Inherited from
FunFixtures
class FunFixture[T]
Inherited from
FunFixtures
final class SuiteTransform(val name: String, fn: List[Test] => List[Test])
Inherited from
SuiteTransforms
final class TestTransform(val name: String, fn: Test => Test)
Inherited from
TestTransforms
final class ValueTransform(val name: String, fn: PartialFunction[Any, Future[Any]])
Inherited from
ValueTransforms

Inherited types

final type AfterEach = GenericAfterEach[TestValue]
Inherited from
Suite
final type BeforeEach = GenericBeforeEach[TestValue]
Inherited from
Suite
final type Test = GenericTest[TestValue]
Inherited from
Suite
final type TestValue = Future[Any]
Inherited from
FunSuite

Value members

Concrete methods

override def munitTimeout: Duration
Definition Classes
FunSuite
Definition Classes
ValueTransforms
final override def test(name: String)(body: => Any)(loc: Location): Unit
Definition Classes
FunSuite
final override def test(options: TestOptions)(body: => Any)(loc: Location): Unit
Definition Classes
FunSuite

Inherited methods

def afterAll(): Unit

Runs once after all test cases and after all suite-local fixtures have been tear down.

Runs once after all test cases and after all suite-local fixtures have been tear down.

Inherited from
Suite
def afterEach(context: AfterEach): Unit

Runs after each individual test case.

Runs after each individual test case.

Inherited from
Suite
def assert(cond: => Boolean, clue: => Any)(loc: Location): Unit
Inherited from
Assertions
def assertEquals[A, B](obtained: A, expected: B, clue: => Any)(loc: Location, ev: B <:< A): Unit

Asserts that two elements are equal using == equality.

Asserts that two elements are equal using == equality.

The "expected" value (second argument) must have the same type or be a subtype of the "obtained" value (first argument). For example:

 assertEquals(Option(1), Some(1)) // OK
 assertEquals(Some(1), Option(1)) // Error: Option[Int] is not a subtype of Some[Int]

Use assertEquals[Any, Any](a, b) as an escape hatch to compare two values of different types. For example:

 val a: Either[List[String], Int] = Right(42)
 val b: Either[String, Int]       = Right(42)
 assertEquals[Any, Any](a, b) // OK
 assertEquals(a, b) // Error: Either[String, Int] is not a subtype of Either[List[String], Int]
Inherited from
Assertions
def assertEqualsDouble(obtained: Double, expected: Double, delta: Double, clue: => Any)(loc: Location): Unit

Asserts that two doubles are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Double.NaN, Double.NaN, *) passes.

Asserts that two doubles are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Double.NaN, Double.NaN, *) passes.

Inherited from
Assertions
def assertEqualsFloat(obtained: Float, expected: Float, delta: Float, clue: => Any)(loc: Location): Unit

Asserts that two floats are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Float.NaN, Float.NaN, *) passes.

Asserts that two floats are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Float.NaN, Float.NaN, *) passes.

Inherited from
Assertions
def assertLeft[L](a: Either[L, _])(expected: L)(loc: Location): Unit
Inherited from
PureharmAssertions
def assertNoDiff(obtained: String, expected: String, clue: => Any)(loc: Location): Unit
Inherited from
Assertions
def assertNotEquals[A, B](obtained: A, expected: B, clue: => Any)(loc: Location, ev: A =:= B): Unit
Inherited from
Assertions
def assertRight[R](a: Either[_, R])(expected: R)(loc: Location): Unit
Inherited from
PureharmAssertions
def assertSome[T](o: Option[T])(expected: T)(loc: Location): Unit
Inherited from
PureharmAssertions
def assertSuccess[T](a: Attempt[T])(expected: T)(loc: Location): Unit
Inherited from
PureharmAssertions
def assume(cond: Boolean, clue: => Any)(loc: Location): Unit
Inherited from
Assertions
def beforeAll(): Unit

Runs once before all test cases and before all suite-local fixtures are setup. An error in this method aborts the test suite.

Runs once before all test cases and before all suite-local fixtures are setup. An error in this method aborts the test suite.

Inherited from
Suite
def beforeEach(context: BeforeEach): Unit

Runs before each individual test case. An error in this method aborts the test case.

Runs before each individual test case. An error in this method aborts the test case.

Inherited from
Suite
def clue[T](c: Clue[T]): T
Inherited from
Assertions
def clues(clue: Clue[_]*): Clues
Inherited from
Assertions
inline def compileErrors(inline code: String): String
Inherited from
CompileErrorMacro
def fail(message: String, clues: Clues)(loc: Location): Nothing
Inherited from
Assertions
def fail(message: String, cause: Throwable)(loc: Location): Nothing
Inherited from
Assertions
def failComparison(message: String, obtained: Any, expected: Any, clues: Clues)(loc: Location): Nothing
Inherited from
Assertions
def failSuite(message: String, clues: Clues)(loc: Location): Nothing
Inherited from
Assertions
def intercept[T <: Throwable](body: => Any)(T: ClassTag[T], loc: Location): T
Inherited from
Assertions
def interceptFailure[E <: Throwable](a: Either[Throwable, _])(ct: ClassTag[E], loc: Location): E
Inherited from
PureharmAssertions
def interceptFailureMessage[E <: Throwable](expectedExceptionMessage: String)(a: Either[Throwable, _])(ct: ClassTag[E], loc: Location): E
Inherited from
PureharmAssertions
def interceptMessage[T <: Throwable](expectedExceptionMessage: String)(body: => Any)(T: ClassTag[T], loc: Location): T
Inherited from
Assertions
def isCI: Boolean
Inherited from
SuiteTransforms
def munitAnsiColors: Boolean
Inherited from
Assertions
def munitCaptureClues[T](thunk: => T): (T, Clues)
Inherited from
Assertions
def munitExecutionContext: ExecutionContext
Inherited from
Suite
Inherited from
TestTransforms
def munitFixtures: Seq[Fixture[_]]

Functinonal fixtures that can be reused for individual test cases or entire suites.

Functinonal fixtures that can be reused for individual test cases or entire suites.

Inherited from
Suite
def munitFlakyOK: Boolean
Inherited from
TestTransforms
Inherited from
TestTransforms
Inherited from
ValueTransforms
def munitIgnore: Boolean
Inherited from
SuiteTransforms
Inherited from
SuiteTransforms
Inherited from
SuiteTransforms
def munitPrint(clue: => Any): String
Inherited from
Assertions
final def munitSuiteTransform(tests: List[Test]): List[Test]
Inherited from
SuiteTransforms
Inherited from
SuiteTransforms
final def munitTestTransform(test: Test): Test
Inherited from
TestTransforms
Inherited from
TestTransforms
def munitTests(): Seq[Test]
Inherited from
FunSuite
final def munitValueTransform(testValue: => Any): Future[Any]
Inherited from
ValueTransforms

Deprecated and Inherited methods

@deprecated("Use interceptFailure", "0.2.0")
def assertFailure[E <: Throwable](a: Either[Throwable, _])(ct: ClassTag[E], loc: Location): E
Deprecated
Inherited from
PureharmAssertions

Inherited fields

val munitLines: Lines
Inherited from
Assertions
final val munitTestsBuffer: ListBuffer[Test]
Inherited from
FunSuite

Implicits

Implicits

See also

PureharmTestRuntimeLazyConversions for details as to why this is a def

implicit def testLogger: TestLogger

Inherited implicits

implicit def phrtToBL(phtr: PureharmTestRuntime): Blocker
implicit def phrtToBS(phtr: PureharmTestRuntime): BlockingShifter[IO]
implicit def phrtToCS(phtr: PureharmTestRuntime): ContextShift[IO]
implicit def phrtToEC(phtr: PureharmTestRuntime): ExecutionContext
implicit def phrtToTM(phtr: PureharmTestRuntime): Timer[IO]
implicit def testOptionsFromString(name: String)(loc: Location): TestOptions

Implicitly create a TestOptions given a test name. This allows writing test("name") { ... } even if test accepts a TestOptions

Implicitly create a TestOptions given a test name. This allows writing test("name") { ... } even if test accepts a TestOptions

Inherited from
TestOptionsConversions