-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Setup Kotest runner with output #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Setup Kotest runner with output #70
Conversation
Unsure on the name here, but just using this as of right now and we can change it later
Simple kotest test runner that uses the TestEngineListener to listen to all tests output in order to construct a JSON report. Currently, the specs that it's finding are hardcoded.
This is missing some features and lacks error handling when Kotest fails to run the tests in the first place.
listOf( | ||
Class.forName("org.example.KotestFunSpec").kotlin, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO here, need to actually allow for passing in the classes to run
val result = runner.run(runnableClasses) | ||
when (result) { | ||
is TestRunResult.Success -> result.report | ||
is TestRunResult.Failure -> TODO() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea what we should do when this fails, I imagine we want to spit out some JSON that explains what went wrong here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that makes sense, on the lua side we can probably handle that by printing that into the overall output and failing all test cases with a generic error that basically says to look at the output for more information.
It doesn't look like you'd normally get this output and that it would either be a mistake on our end, or an internal kotest error.
@JsonClassDiscriminator("type") | ||
@Serializable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using Kotlinx serialization here, which is nice and all, but have some caveats from good ole Jackson. Namely, the fields in TestNode.Container
for status
and duration
aren't evaluated because they're not backed fields. I'll probably pivot away from this if there's no way to handle this.
Failure.Error( | ||
message = it.message, | ||
lineNumber = traceOrigin?.lineNumber, | ||
filename = traceOrigin?.fileName, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mostly works, outside of soft assertions which seem to reference a lineNumber that is higher than the file. Maybe just need to specially handle that?
.../app/src/test/kotlin/io/github/codymikol/neotestkotlin/framework/kotest/KotestExampleSpec.kt
Outdated
Show resolved
Hide resolved
[ | ||
{ | ||
"name": "io.github.codymikol.neotestkotlin.framework.kotest.KotestExampleSpec", | ||
"nodes": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't love the "nodes" naming here, but we effectively have a tree. I also don't know a good word for either a Container or a Test
.../kotlin/io/github/codymikol/neotestkotlin/framework/kotest/KotestTestRunnerFunctionalSpec.kt
Outdated
Show resolved
Hide resolved
Better name for the project
This will be the base for the gradle plugin and keep the core logic of running and discovering based on Frameworks opaque and following a contract.
This makes it easier to use in the context of the gradle plugin
this is just a simple maven plugin that can eventually hook into the core lib Fixes N/A
for consistency Fixes N/A
Takes in classes via -Pclasses=org.example.KotestFunSpec and writes to the output file in the build
|
||
classes.set(project.properties["classes"]?.toString()) | ||
|
||
outputFile.convention(project.layout.buildDirectory.file("$name/output-${UUID.randomUUID()}.json")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently just dumping to a randomly named output JSON file, but we should be good to provide a custom file via -PoutputFile=/path/to/output/file/here.json
This now leverages the kotlin-test-launcher plugin
Feels more clear than having two nested statuses
Prevent execution of multiple of the same class
Relates to #65
Goals