Skip to content

Test generator - #3186

Open
jagdish-15 wants to merge 11 commits into
exercism:mainfrom
jagdish-15:test-generator
Open

jagdish-15 wants to merge 11 commits into
exercism:mainfrom
jagdish-15:test-generator

Conversation

@jagdish-15

Copy link
Copy Markdown
Member

Summary

Adds an automated JUnit 5 test generator CLI tool (./bin/generate-tests) and custom Handlebars templates for exercises requiring track-specific signatures.

Changes

  • test-generator/: CLI tool to fetch canonical data from problem-specifications, apply .meta/tests.toml, and generate formatted JUnit 5 tests.
  • Templates: Added .meta/template.hbs for practice exercises with non-standard APIs/signatures.
  • Fixes: Minor fixes in simple-cipher reference solution, clock test consolidation into ClockTest.java, and list-ops foldLeft argument order.

Usage

# Build & install
cd test-generator && ./gradlew installDist

# Generate tests
./bin/generate-tests -e <exercise-slug>
./bin/generate-tests -a

@github-actions

Copy link
Copy Markdown
Contributor

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

@jagdish-15
jagdish-15 requested a review from kahgoh November 24, 2026 12:28
@jagdish-15
jagdish-15 requested review from kahgoh and removed request for kahgoh November 27, 2026 12:58

@kahgoh kahgoh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work! I think this looks pretty good! I have some comments below. I was also wondering if you have tried running it and seeing if there is much of a diff between the existing tests and the generated tests? I'm wondering if we'll be able to use [no important files change] for the first sync.


public static String toMethodName(String description) {
if (description == null || description.isBlank()) {
return "testMethod";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it better to throw some kind of exception? If we just return testMethod, there is the possibility of multiple descriptions that is either null or blank.

Comment thread test-generator/README.md Resolved
Comment thread test-generator/gradlew

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should add execute permission on this file so that Git makes this executable when cloned and checked out (see https://dev.to/antozanini/how-to-mark-a-file-as-executable-in-a-git-repo-1ml0)

Comment thread bin/generate-tests

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar to another comment, we should add the execute permission for this script in the Git repository.

@jagdish-15

Copy link
Copy Markdown
Member Author

I was also wondering if you have tried running it and seeing if there is much of a diff between the existing tests and the generated tests? I'm wondering if we'll be able to use [no important files change] for the first sync.

Yep, I did!
There wasn't much of a difference except the formatting stuff. We can safely use [no important files change].
(Not so sure about simple cipher though, that was the only one where the actual test got changed)

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