Skip to content

Make the prefix of generated functions customisable through KSP arguments#9

Open
arekolek wants to merge 1 commit into
bluegroundltd:masterfrom
arekolek:feature/custom-prefix
Open

Make the prefix of generated functions customisable through KSP arguments#9
arekolek wants to merge 1 commit into
bluegroundltd:masterfrom
arekolek:feature/custom-prefix

Conversation

@arekolek

Copy link
Copy Markdown
Contributor

This feature allows for easier adoption of the library when existing code base uses a different convention for naming test fixtures.

For example instead of createFoo() there might be newFoo(), getFoo(), or simply foo().

@St4B St4B left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! This is something we were considering introducing. We discussed adding a field to the annotation to allow different configurations per fixture. It’s a slightly different approach, but something we could explore in the future. 🙂

"$functionName()"
}

else -> error("${parameter.typeName}.${sealedEntry.name} must be an object or fixture based on filter in preconditions")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 This is very helpful for understanding on which class the generation failed. Great addition!

parameter.entries.random()
val entries = parameter.entries.filter { it.isObject || it.isFixture }
require(entries.isNotEmpty()) {
"At least one sealed data class annotated with @Fixture is required in: ${parameter.type.copy(nullable = false)}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message might not fully account for scenarios where we have only objects, which is valid. Should we update it to reflect this case for better accuracy? 🤔

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