Integration tests from IDEA : no enhancing

Hi

I created integration tests following the doc, and run them from IDEA.

I have the issue “XXX is a ChangeTracker but has no PropertyChangeListener”. Which is I learned here is due to not using enhanced classes.

I have other lines in the test logs hinting another consequence of not using enhanced classes.


19:18:03.828 WARN  eclipselink.metadata - metadata_warning_ignore_lazy [order, class com.app.entity.com.Invoice]

I checked the classpath of the test, it is using the directory \build\production\app-global_main\com\app\entity, and does not contain enhanced classes.

How can I run integration tests from IDEA while using enhanced classes?

Mike

Hi Mike,

Make sure your IDEA project configuration has build/enhanced-classes/main entry for the global module. If it doesn’t, clean IDEA project files and create them again.

I recreated completely the project under IDEA, by deleting .idea directory and starting from scratch (studio clean did not change anything visible).

Created IDEA files from Studio and also Gradle Wrapper.

So from scratch, project is configured as following :

  • Project directory output : none
  • app-core, app-global, app-gui, app-web, app-web-toolkit use “Inherit project compile output path”
  • app-web-themes use module output path : \modules\web\build\scss-themes\classes\main & test

Which does not work out of the box. Defined the project output path to standard IDEA : \out. Could compile and run my tests from IDEA.

But still have the exception : “XXX is a ChangeTracker but has no PropertyChangeListener” => either I do not understand what you propose, or creating IDEA project files from Studio simply does not set the enhanced class path you mention.

Tried another sample project (google map) : same project structure.

Tried the Sales sample project which is supposed to have a working example of integration tests. Same project structure. And sample integration test does not work out of the box, which really really does not help (I have open another thread for this one).

Could you make a sample project with working integration tests ?

(studio 6.6.1, platform 6.6.1)

Mike

Please do the following:

  • In Studio, Build > Create or update Gradle wrapper. This will ensure you use correct Gradle version further.
  • Build > Remove IDE project files. Make sure there are no .ipr and .iml files in the project directory. The same can be done from the command line: gradlew cleanIdea
  • Build > Create or update IDE project files (gradlew idea).
  • Build > Assemble project (gradlew assemble).
  • Click IDE button in Studio, or open .ipr file in IDEA. Never open build.gradle or directory, so there should be no .idea folder in your project.
    Make sure there is build/enhanced-classes/main folder in the global module and the corresponding entry in IDEA project configuration. The folder must contain enhanced classes of entities.
    That’s it. Tests will work from IDEA, as well as from the command line (gradlew test).

Tests are working now, great. Thanks Konstantin.

We had a misunderstanding : when you refered to IDA project configuration containing entry with enhanced-classes, I was thinking about the ‘Path’ tab (first screenshot) attached and not the ‘Sources’. My bad.

But the fact is, the ‘Sources’ tab in my project previously was identical to the one I have now, thus containing the build/enhanced-classes in the directory structure (second screenshot attached).

So I analyzed classpath generated by IDEA when running tests and for discovered that for some reason it was using its own one ‘out/production/[etc…]’ instead.

Maybe because of the .idea dir, maybe because of the 'Import graddle project I’ve done long ago (the project is more than 1 year old).

I guess you do not recommend importing Gradle project in IDEA ? If true I can live with graddling from studio.

Mike

cuba_project_struct_global_no_enhanced_in_output_path

cuba_project_struct_global_enhanced_in_dir_struc

Hi Mike,

IDEA compilation path is set to its own “out/production/…” deliberately, to be sure IDEA does not override enhanced classes and to be sure we test the same classes that go to the final product JAR. So the IDEA compilation is in fact needed only for HotSpot redeploy sometimes. Tests should work with the classes built by Gradle, so you need to assemble before running tests from IDEA.

We definitely don’t recommend importing Gradle project, at least until we fix this issue: https://youtrack.cuba-platform.com/issue/PL-8093. But you don’t need to resort to Studio for running Gradle, IDEA has an embedded terminal and the external tools integration where you can assign shortcuts to commands, for example to gradlew restart.