robfletcher
01/25/2021, 3:34 PMfun loginUser() = before {
// do login things that may throw exceptions
}
christophsturm
01/25/2021, 3:34 PMchristophsturm
01/25/2021, 3:36 PMchristophsturm
01/25/2021, 3:36 PMrobfletcher
01/25/2021, 3:36 PMdmcg
01/26/2021, 7:35 AMdmcg
01/26/2021, 7:37 AMdmcg
01/26/2021, 7:39 AMdmcg
01/26/2021, 7:40 AMdmcg
01/26/2021, 7:42 AMdmcg
01/26/2021, 7:45 AMdmcg
01/26/2021, 7:47 AMchristophsturm
01/26/2021, 11:24 AMchristophsturm
01/26/2021, 11:32 AMchristophsturm
01/26/2021, 11:33 AMdmcg
01/26/2021, 11:34 AMchristophsturm
01/26/2021, 11:35 AMdmcg
01/26/2021, 11:35 AMdmcg
01/26/2021, 3:13 PM## 2.0.0-alpha
### DSL changes (old methods deprecated)
* before -> beforeEach
* after -> afterEach
* fixture -> given
* modifyFixture -> beforeEach
* deriveFixture -> given_
### DSL changes (old methods renamed)
* test and test_ no longer take a TestDescriptor parameter to their block, but do supply the fixture as both receiver and parameter. The old versions are available as old_test and old_test_.
### Other DSL changes
DSL functions with TestDescriptors are available in an Instrumented object.
### Test Engine
The JUnit 5 (not Jupiter) test engine is now working well.
It should find methods or top-level functions annotated @Testable, and you can even point to methods in IntelliJ and run them.
Add this to Gradle to enable
tasks.withType<Test> {
useJUnitPlatform {
includeEngines(
"junit-jupiter",
"minutest" <-- This
)
}
### Parallel Test Running
Run tests in each root context in parallel by setting a system property dev.minutest.parallel.
Parallel running isn't on by default yet, but seems solid.
dmcg
01/26/2021, 3:18 PMdmcg
01/26/2021, 9:00 PMdmcg
03/31/2021, 6:04 PMdmcg
03/31/2021, 6:05 PMdmcg
03/31/2021, 6:10 PMderivedContext
to context_
(with an underscore) to match the rename of deriveFixture
to given_
dmcg
03/31/2021, 9:31 PMDavid Hamilton
09/17/2023, 11:47 AMdmcg
09/18/2023, 10:00 PMdmcg
09/18/2023, 10:00 PMchristophsturm
12/01/2023, 6:51 PMval context = describe {
val assertionError: AssertionError = AssertionError("failed")
describe("with a typical valid root context") {
val ctx =
RootContext("root context") {
test("failed test") { throw assertionError }
}
describe("executing all the tests") {
val contextInfo = assertNotNull(execute(ctx) as? ContextInfo)
describe("reports failed tests") {
val failure =
contextInfo.tests.values
.awaitAll()
.map { it.result }
.filterIsInstance<Failure>()
.single()
it("reports exception for failed tests") {
expectThat(failure.failure) {
get { stackTraceToString() }
.isEqualTo(assertionError.stackTraceToString())
}
}
}
so the fixture is basically the rootcontext (ctx), and the assertionError (because in the test I need to have the assertion error to check that exactly that error is reported as failure)
when I try to convert this to a given style (with my own made up test dsl) I have to make the context field nullable and mutable, because I need the given class constructed to reference the exception in my context.
data class Given(
val assertionError: java.lang.AssertionError,
var context: RootContext? = null
)
val test =
context(
"contextExecutorTest port",
given = {
val given = Given(AssertionError("failed"))
given.context =
RootContext("root context") {
test("failed test") {
throw given.assertionError
}
}
given
}
)
is there a better way to do this and avoid making the context nullable?