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

Allow a custom function to name a test #2507

Closed
Tracked by #2226
jschneidereit opened this issue Sep 14, 2021 · 0 comments · Fixed by #2512
Closed
Tracked by #2226

Allow a custom function to name a test #2507

jschneidereit opened this issue Sep 14, 2021 · 0 comments · Fixed by #2512
Labels
enhancement ✨ Suggestions for adding new features or improving existing ones. framework 🏗️ Pertains to the core structure and components of the Kotest framework.
Milestone

Comments

@jschneidereit
Copy link
Member

Right now we allow users to append tags to tests names, which is fine - but it would be even better to provide users an extension point to modify the name of the tests based on the test itself and tags (and perhaps other information).

Given a test with tags Slow and NickNack

status quo:

TestClass.nicknack does some stuff[tags = Slow, NickNack]

new hotness, in kotlin pseudocode:

val Slow = Tag("Slow")

val testNamer = object : TestNameExtension {
  override fun nameTest(testCase: TestCase, tags: Set<Tag>): String {
    if (tags.contains(Slow)) {
      return "Slow: ${testCase.name} [tags=${(tags - Slow).joinToString()}]"
   }
   return testCase.name

would give us a nice test name like

Slow: TestClass.nicknack does some stuff [tags = NickNack]
@jschneidereit jschneidereit added the enhancement ✨ Suggestions for adding new features or improving existing ones. label Sep 14, 2021
@sksamuel sksamuel modified the milestones: 4.6.2, 5.0 Sep 14, 2021
@sksamuel sksamuel added the framework 🏗️ Pertains to the core structure and components of the Kotest framework. label Sep 14, 2021
@sksamuel sksamuel mentioned this issue Sep 14, 2021
71 tasks
sksamuel added a commit that referenced this issue Sep 16, 2021
* Added display name format extension point #2507

* Added display name format extension point #2507
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ Suggestions for adding new features or improving existing ones. framework 🏗️ Pertains to the core structure and components of the Kotest framework.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants