Test generated code that includes Maven dependencies [message #1822518] |
Mon, 09 March 2020 05:32  |
Eclipse User |
|
|
|
Hello,
From my DSL I generate Java code which depends on libraries that are resolved through Maven (e.g. a web framework). I would like to write automated tests that test the behavior of the generated classes.
I have looked at the CompilationTestHelper class, which allows me to access the generated classes, but it does not seem like it's able to resolve Maven dependencies.
I have also looked at workbench tests, by extending the AbstractWorkbenchTest class, which seems to be able to resolve Maven dependencies by invoking 'waitForBuild()', but I can't figure out a way to get the generated classes from here.
[Updated on: Mon, 09 March 2020 05:33] by Moderator
|
|
|
|
|
|
Re: Test generated code that includes Maven dependencies [message #1822641 is a reply to message #1822639] |
Tue, 10 March 2020 12:58  |
Eclipse User |
|
|
|
I think you try to do in a unit test what is actually an integration test. In a unit test you should not integrate with Maven, just check that the code is generated as you would like to have it.
For your Maven integration scenario create a reference project that contains DSL files just for testing, invoke the code generator within Maven and write unit tests against the generated code.
A reference project should contain a minimal consistent project with DSL files, generated and manual code. It is a stripped down version of your real project. By doing so, your generator is tested by executing it, and let the build system build what you generated.
I'd not recommend trying to resolve Maven dependencies and do other fancy stuff in your generator's unit tests. You can continue, but then without help.
|
|
|
Powered by
FUDForum. Page generated in 0.03954 seconds