Skip to content

#129 testmodule#131

Merged
phax merged 14 commits into
phax:masterfrom
glelouet:#129_testmodule
May 7, 2026
Merged

#129 testmodule#131
phax merged 14 commits into
phax:masterfrom
glelouet:#129_testmodule

Conversation

@glelouet
Copy link
Copy Markdown
Contributor

@glelouet glelouet commented Feb 27, 2026

Have not worked it in a few weeks so I forgot details but …

Implementation for #129

  1. add a module dedicated to simple tests : JCodeModel-Tests in /jcodemodeltests
  2. generating classes are in the src/main/java ; annotated with new annotation @TestJCM
  3. their public method that produce a JCodemodel from nothing are called after instantiation (or statically if static)
  4. the JCM is then written in the src/generated/javatest which is bound to test phases
  5. the actual tests using those classes are in the usual src/test/java.

This mean you can see what is actually created, work with generated behaviour (and not code only) since you can load the generated class in tests.

I recommend using the same method names for the generation and the test so as to know what you are testing exactly ; and suffix "Gen" at the end of the class generating (the one that is annotated @TestJCM) .
For example, I want to test the record, RecordTestGen is annotated in src/main/java, has a simplerecordtest() method ; and RecordTest is the @Test in src/test/java, has the same simplerecordtest() method.

I only integrated the records tests

@glelouet glelouet mentioned this pull request Mar 1, 2026
@phax phax merged commit 5886727 into phax:master May 7, 2026
1 check passed
@glelouet
Copy link
Copy Markdown
Contributor Author

glelouet commented May 7, 2026

@phax opinion on the feature ?
I guess barely useful without explanation.
IMO there are several benefits :

1.visually see the result as we make the tests
2. load the generated test classes in tests for complex unit tests
3. keep an history of what is changed in the generation after a change : we know what trigggered a change say in indentation.

@glelouet glelouet deleted the #129_testmodule branch May 7, 2026 20:50
@phax
Copy link
Copy Markdown
Owner

phax commented May 8, 2026

Well it was more tests and examples - tests and examples are always good. It was a pragmatic approach without investing too much review time - your contributions usually make sense :-)

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