PureharmTest
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.
Type members
Classlikes
The pattern is rather straightforward:
The pattern is rather straightforward:
final class MyTest extends PureharmTest {
private val myComplexTestFixture = ResourceFixture {testOptions =>
Resource.pure("maybe use testOptions to create a database name or something")
}
myComplexTestFixuture.test("testing w/ setup and teardown") { acquiredResource =>
//write test
//at the end of the test, the resource gets cleaned up as per semantics of Resource.
}
}
Inherited classlikes
- Value Params
- name
The name of this fixture, used for displaying an error message if
beforeAll()
orafterAll()
fail.
- Inherited from
- Suite
Inherited types
Value members
Inherited methods
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
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
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
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
- Inherited from
- Assertions
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
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
- Inherited from
- Assertions
- Inherited from
- PureharmAssertions
- Inherited from
- PureharmAssertions
- Inherited from
- Assertions
Deprecated and Inherited methods
- Deprecated
- Inherited from
- PureharmAssertions