Skip to content
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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arekolek
Copy link
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().

Copy link
Collaborator

@St4B St4B left a comment

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
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
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