Skip to content

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

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from

Conversation

NickHackman
Copy link
Collaborator

⚠️ This is a work in progress ⚠️

Relates to #65

Goals

  • Have an executable / gradle plugin
  • Execute Kotest tests
  • Standardize output for neotest-kotlin usage
  • integrate with neotest-kotlin
  • remove Lua output parsing

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.
Comment on lines 11 to 13
listOf(
Class.forName("org.example.KotestFunSpec").kotlin,
)
Copy link
Collaborator Author

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()
Copy link
Collaborator Author

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?

Copy link
Owner

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.

Comment on lines 16 to 17
@JsonClassDiscriminator("type")
@Serializable
Copy link
Collaborator Author

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.

docs

Comment on lines 143 to 147
Failure.Error(
message = it.message,
lineNumber = traceOrigin?.lineNumber,
filename = traceOrigin?.fileName,
)
Copy link
Collaborator Author

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?

[
{
"name": "io.github.codymikol.neotestkotlin.framework.kotest.KotestExampleSpec",
"nodes": [
Copy link
Collaborator Author

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

NickHackman and others added 10 commits July 22, 2025 01:07
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"))
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants