hibernate / hibernate-test-case-templates

Templates and examples to report issues to Hibernate
61 stars 348 forks source link

hibernate-orm-6 runs no tests for 6.6.0.Final #417

Closed tomas-muller closed 2 months ago

tomas-muller commented 2 months ago

I am trying to create a test case for a bug I am experiencing in Hibernate 6.6.0; however, mvn test under hibernate-orm-6 does not execute any tests:

hibernate-orm-6 % mvn test
[INFO] Scanning for projects...
[INFO] 
[INFO] --< org.hibernate.testcasetemplate:test-case-template-hibernate-orm-6 >--
[INFO] Building Hibernate ORM 6 Test Case Template 1.0.0.Final
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ test-case-template-hibernate-orm-6 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/muller/git/hibernate-test-case-templates/orm/hibernate-orm-6/src/main/resources
[INFO] 
[INFO] --- compiler:3.13.0:compile (default-compile) @ test-case-template-hibernate-orm-6 ---
[INFO] No sources to compile
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ test-case-template-hibernate-orm-6 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources from src/test/resources to target/test-classes
[INFO] 
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ test-case-template-hibernate-orm-6 ---
[INFO] Nothing to compile - all classes are up to date.
[INFO] 
[INFO] --- hibernate-enhance:6.6.0.Final:enhance (default) @ test-case-template-hibernate-orm-6 ---
[WARNING] Skipping Hibernate bytecode enhancement plugin execution since no feature is enabled
[INFO] 
[INFO] --- surefire:3.2.2:test (default-test) @ test-case-template-hibernate-orm-6 ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.797 s
[INFO] Finished at: 2024-08-12T17:46:32+02:00
[INFO] ------------------------------------------------------------------------

I created a fresh copy of the templates with no files changed. When I set the version.org.hibernate.orm back to 6.5.2.Final in pom.xml, there are four tests (those hhh123Test) executed:

% mvn test
[INFO] Scanning for projects...
[INFO] 
[INFO] --< org.hibernate.testcasetemplate:test-case-template-hibernate-orm-6 >--
[INFO] Building Hibernate ORM 6 Test Case Template 1.0.0.Final
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ test-case-template-hibernate-orm-6 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/muller/git/hibernate-test-case-templates/orm/hibernate-orm-6/src/main/resources
[INFO] 
[INFO] --- compiler:3.13.0:compile (default-compile) @ test-case-template-hibernate-orm-6 ---
[INFO] No sources to compile
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ test-case-template-hibernate-orm-6 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources from src/test/resources to target/test-classes
[INFO] 
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ test-case-template-hibernate-orm-6 ---
[INFO] Nothing to compile - all classes are up to date.
[INFO] 
[INFO] --- hibernate-enhance:6.5.2.Final:enhance (default) @ test-case-template-hibernate-orm-6 ---
[WARNING] Skipping Hibernate bytecode enhancement plugin execution since no feature is enabled
[INFO] 
[INFO] --- surefire:3.2.2:test (default-test) @ test-case-template-hibernate-orm-6 ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
2024-08-12 17:50:23 INFO  Version:44 - HHH000412: Hibernate ORM core version 6.5.2.Final
2024-08-12 17:50:23 INFO  Environment:148 - HHH000205: Loaded properties from resource hibernate.properties: {hibernate.format_sql=true, jakarta.persistence.validation.mode=NONE, hibernate.dialect=org.hibernate.dialect.H2Dialect, hibernate.connection.username=sa, hibernate.connection.url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1, hibernate.max_fetch_depth=5, hibernate.show_sql=false, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.driver_class=org.h2.Driver, hibernate.connection.password=****, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.pool_size=5, hibernate.cache.region.factory_class=org.hibernate.testing.cache.CachingRegionFactory, hibernate.service.allow_crawling=false, hibernate.session.events.log=true}
[INFO] Running org.hibernate.bugs.JPAUnitTestCase
2024-08-12 17:50:24 INFO  LogHelper:31 - HHH000204: Processing PersistenceUnitInfo [name: templatePU]
2024-08-12 17:50:24 WARN  CachingRegionFactory:48 - org.hibernate.testing.cache.CachingRegionFactory should be only used for testing.
2024-08-12 17:50:24 INFO  RegionFactoryInitiator:53 - HHH000025: Second-level cache region factory [org.hibernate.testing.cache.CachingRegionFactory]
2024-08-12 17:50:24 WARN  pooling:81 - HHH10001002: Using built-in connection pool (not intended for production use)
2024-08-12 17:50:24 INFO  pooling:136 - HHH10001005: Loaded JDBC driver class: org.h2.Driver
2024-08-12 17:50:24 INFO  pooling:158 - HHH10001012: Connecting with JDBC URL [jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1]
2024-08-12 17:50:24 INFO  pooling:167 - HHH10001001: Connection properties: {password=****, user=sa}
2024-08-12 17:50:24 INFO  pooling:171 - HHH10001003: Autocommit mode: false
2024-08-12 17:50:24 INFO  pooling:372 - HHH10001115: Connection pool size: 5 (min=1)
2024-08-12 17:50:24 WARN  deprecation:153 - HHH90000025: H2Dialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-12 17:50:24 INFO  JtaPlatformInitiator:56 - HHH000490: Using JTA platform [org.hibernate.engine.transaction.jta.platform.internal.WildFlyStandAloneJtaPlatform]
2024-08-12 17:50:24 INFO  StatisticalLoggingSessionEventListener:280 - Session Metrics {
    27416 nanoseconds spent acquiring 1 JDBC connections;
    41917 nanoseconds spent releasing 1 JDBC connections;
    0 nanoseconds spent preparing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC batches;
    0 nanoseconds spent performing 0 L2C puts;
    0 nanoseconds spent performing 0 L2C hits;
    0 nanoseconds spent performing 0 L2C misses;
    0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
    0 nanoseconds spent executing 0 pre-partial-flushes;
    0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
}
2024-08-12 17:50:24 INFO  pooling:607 - HHH10001008: Cleaning up connection pool [jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.357 s -- in org.hibernate.bugs.JPAUnitTestCase
[INFO] Running org.hibernate.bugs.ORMUnitTestCase
2024-08-12 17:50:24 INFO  CustomRunner:126 - BeforeClass: org.hibernate.bugs.ORMUnitTestCase
2024-08-12 17:50:24 WARN  CachingRegionFactory:48 - org.hibernate.testing.cache.CachingRegionFactory should be only used for testing.
2024-08-12 17:50:24 INFO  RegionFactoryInitiator:53 - HHH000025: Second-level cache region factory [org.hibernate.testing.cache.CachingRegionFactory]
2024-08-12 17:50:24 WARN  pooling:81 - HHH10001002: Using built-in connection pool (not intended for production use)
2024-08-12 17:50:24 INFO  pooling:136 - HHH10001005: Loaded JDBC driver class: org.h2.Driver
2024-08-12 17:50:24 INFO  pooling:158 - HHH10001012: Connecting with JDBC URL [jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1]
2024-08-12 17:50:24 INFO  pooling:167 - HHH10001001: Connection properties: {password=****, user=sa}
2024-08-12 17:50:24 INFO  pooling:171 - HHH10001003: Autocommit mode: false
2024-08-12 17:50:24 INFO  pooling:372 - HHH10001115: Connection pool size: 5 (min=1)
2024-08-12 17:50:24 WARN  deprecation:153 - HHH90000025: H2Dialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-12 17:50:24 INFO  JtaPlatformInitiator:56 - HHH000490: Using JTA platform [org.hibernate.engine.transaction.jta.platform.internal.WildFlyStandAloneJtaPlatform]
2024-08-12 17:50:24 INFO  CustomRunner:133 - Test: hhh123Test
2024-08-12 17:50:24 INFO  StatisticalLoggingSessionEventListener:280 - Session Metrics {
    0 nanoseconds spent acquiring 0 JDBC connections;
    0 nanoseconds spent releasing 0 JDBC connections;
    0 nanoseconds spent preparing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC batches;
    0 nanoseconds spent performing 0 L2C puts;
    0 nanoseconds spent performing 0 L2C hits;
    0 nanoseconds spent performing 0 L2C misses;
    0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
    0 nanoseconds spent executing 0 pre-partial-flushes;
    0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
}
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.050 s -- in org.hibernate.bugs.ORMUnitTestCase
[INFO] Running org.hibernate.bugs.QuarkusLikeORMUnitTestCase
2024-08-12 17:50:24 INFO  CustomRunner:126 - BeforeClass: org.hibernate.bugs.QuarkusLikeORMUnitTestCase
2024-08-12 17:50:24 WARN  CachingRegionFactory:48 - org.hibernate.testing.cache.CachingRegionFactory should be only used for testing.
2024-08-12 17:50:24 INFO  RegionFactoryInitiator:53 - HHH000025: Second-level cache region factory [org.hibernate.testing.cache.CachingRegionFactory]
2024-08-12 17:50:24 WARN  deprecation:153 - HHH90000025: H2Dialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-12 17:50:24 INFO  JtaPlatformInitiator:56 - HHH000490: Using JTA platform [org.hibernate.engine.transaction.jta.platform.internal.WildFlyStandAloneJtaPlatform]
[INFO] Running org.hibernate.bugs.QuarkusLikeORMUnitTestCase
2024-08-12 17:50:24 INFO  CustomRunner:133 - Test: hhh123Test
2024-08-12 17:50:24 INFO  StatisticalLoggingSessionEventListener:280 - Session Metrics {
    0 nanoseconds spent acquiring 0 JDBC connections;
    0 nanoseconds spent releasing 0 JDBC connections;
    0 nanoseconds spent preparing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC statements;
    0 nanoseconds spent executing 0 JDBC batches;
    0 nanoseconds spent performing 0 L2C puts;
    0 nanoseconds spent performing 0 L2C hits;
    0 nanoseconds spent performing 0 L2C misses;
    0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
    0 nanoseconds spent executing 0 pre-partial-flushes;
    0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
}
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s -- in org.hibernate.bugs.QuarkusLikeORMUnitTestCase
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.018 s -- in org.hibernate.bugs.QuarkusLikeORMUnitTestCase
[INFO] Running org.hibernate.bugs.ORMStandaloneTestCase
2024-08-12 17:50:24 WARN  CachingRegionFactory:48 - org.hibernate.testing.cache.CachingRegionFactory should be only used for testing.
2024-08-12 17:50:24 INFO  RegionFactoryInitiator:53 - HHH000025: Second-level cache region factory [org.hibernate.testing.cache.CachingRegionFactory]
2024-08-12 17:50:24 WARN  pooling:81 - HHH10001002: Using built-in connection pool (not intended for production use)
2024-08-12 17:50:24 INFO  pooling:136 - HHH10001005: Loaded JDBC driver class: org.h2.Driver
2024-08-12 17:50:24 INFO  pooling:158 - HHH10001012: Connecting with JDBC URL [jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1]
2024-08-12 17:50:24 INFO  pooling:167 - HHH10001001: Connection properties: {password=****, user=sa}
2024-08-12 17:50:24 INFO  pooling:171 - HHH10001003: Autocommit mode: false
2024-08-12 17:50:24 INFO  pooling:372 - HHH10001115: Connection pool size: 5 (min=1)
2024-08-12 17:50:24 WARN  deprecation:153 - HHH90000025: H2Dialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-12 17:50:24 INFO  JtaPlatformInitiator:56 - HHH000490: Using JTA platform [org.hibernate.engine.transaction.jta.platform.internal.WildFlyStandAloneJtaPlatform]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 s -- in org.hibernate.bugs.ORMStandaloneTestCase
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.759 s
[INFO] Finished at: 2024-08-12T17:50:24+02:00
[INFO] ------------------------------------------------------------------------

The only difference is the setting of version.org.hibernate.orm in pom.xml. I can see the four test templates are also executed with version 6.6.0.Alpha1, but not with any later version.

yrodiere commented 2 months ago

I remember experiencing similar problems when attempting to run JUnit 4 tests in Maven with JUnit 5 somehow getting in the classpath, without the corresponding junit-vintage dependency. When that happens, Maven decides to run tests using JUnit 5, and JUnit 5 is unable to find JUnit 4 tests.

I see JUnit 5 is being used to run tests in both cases:

[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider

Maybe there was some dependency change in hibernate-testing causing a similar issue to what I encountered in the past...

@marko-bekhta My bet would be on https://github.com/hibernate/hibernate-orm/commit/19e495d8da7610503afd50083b003de631d25564 being involved in this problem, but I may be wrong. Do you think you could have a look?

marko-bekhta commented 2 months ago

looking ... 🏃🏻

marko-bekhta commented 2 months ago

Thanks @tomas-muller for bringing this up!

I've converted the test case examples to JUnit 5 since we've been using it for a while now for new ORM tests. So it should all be good now, could you pull the latest changes and give it a try with your test case?

tomas-muller commented 2 months ago

@marko-bekhta Yes, it is working for me now. Thank you!