Skip to content

[MDEP-977] Incorrect handling if transitive compile dependency is used in tests #1483

Open
@jira-importer

Description

@jira-importer

Jakub Bochenski opened MDEP-977 and commented

PostgreSQLContainer extends GenericContainer which is a FailureDetectingExernalResource which then implements org.junit.rules.TestRule.

I think the case when you use Testcontainers in your main sources, while also have JUnit tests in your test sources is not handled correctly:

If you declare in pom.xml

<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>postgresql</artifactId>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
</dependency>
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>testcontainers</artifactId>
</dependency>

then the analyze will fail with:

[INFO] --- dependency:3.8.1:analyze-only (analyze-only) @ persistence-test ---
[ERROR] Non-test scoped test only dependencies found:
[ERROR]    junit:junit:jar:4.13.2:compile

This is wrong - Junit needs to be in compile scope because of the Testcontainers classes extending it.


Affects: 3.8.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:majorMajor loss of function

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions