简体   繁体   中英

testcontainers - maven build fails due to test failures

My development environment(JDK, Maven) is setup within WSL2. With this setup, there are test failures

Below is the output of the build process.

00:18:14.261 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.sudhirt.practice.testcontainers.repository.DatabaseTests]        00:18:14.263 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.sudhirt.practice.testcontainers.repository.DatabaseTests]
00:18:14.267 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.sudhirt.practice.testcontainers.repository.DatabaseTests]        00:18:14.268 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.sudhirt.practice.testcontainers.repository.DatabaseTests]
00:18:14.271 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.sudhirt.practice.testcontainers.repository.DatabaseTests]
00:18:14.272 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.sudhirt.practice.testcontainers.repository.DatabaseTests]
00:18:14.303 [main] DEBUG org.testcontainers.utility.TestcontainersConfiguration - Testcontainers configuration overrides will be loaded from file:/home/sudhirtumati/.testcontainers.properties
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.155 s <<< FAILURE! - in com.sudhirt.practice.testcontainers.repository.DatabaseTests
[ERROR] com.sudhirt.practice.testcontainers.repository.DatabaseTests  Time elapsed: 1.151 s  <<< ERROR!                                                                                                                  java.lang.ExceptionInInitializerError
        at com.sudhirt.practice.testcontainers.repository.DatabaseTests.<clinit>(DatabaseTests.java:23)

[INFO]
[INFO] Results:
[INFO]                                                                                                                                                                                                                   [ERROR] Errors:                                                                                                                                                                                                          [ERROR]   DatabaseTests.com.sudhirt.practice.testcontainers.repository.DatabaseTests » ExceptionInInitializer                                                                                                            [INFO]                                                                                                                                                                                                                   [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0                                                                                                                                                                 [INFO]                                                                                                                                                                                                                   [INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

Line 23 of DatabaseTests is:

@ClassRule
public static OracleContainer oracleContainer = new OracleContainer();

The complete source code is available on github .

Any suggestions to fix this issue?

From the documentation of the Oracle-XE Module :

If you do not pass an image name to the OracleContainer constructor, a suitable image name should be placed in configuration instead. To do this, please place a file on the classpath named testcontainers.properties , containing oracle.container.image=IMAGE , where IMAGE is a suitable image name and tag.

I see nothing in your code that does this. new OracleContainer() is not enough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM