Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maven junit test not executed with xchart dependency present #7345

Closed
bernard01 opened this issue Apr 30, 2024 · 1 comment
Closed

maven junit test not executed with xchart dependency present #7345

bernard01 opened this issue Apr 30, 2024 · 1 comment
Labels
kind:bug Bug report or fix Maven [ci] enable "build tools" tests tests

Comments

@bernard01
Copy link

Apache NetBeans version

Apache NetBeans 21

What happened

A maven java project compiles but a junit test is not executed only if a specific dependency exists in the pom.xml file: xchart.

If that dependency is removed and the code using it is commented out, then the test is executed as expected.

The test is executed as expected from the command line:

mvn test -Dtest=ArticlePageParserTest#testParse

Language / Project Type / NetBeans Component

No response

How to reproduce

See description above and attached test case (NetBeans Maven project)
NoTests.zip

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 7

JDK

JDK 21

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

@bernard01 bernard01 added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Apr 30, 2024
@mbien mbien added Maven [ci] enable "build tools" tests tests labels Apr 30, 2024
@matthiasblaesing
Copy link
Contributor

From my POV this project is broken:

  1. The version of the surefire plugin is not configured. Resulting in undefined behavior. I have mvn 3.8.1 installed and NetBeans bundles 3.9.6. Runs with the former give me surefire 2.12.4, with the latter 3.2.2. Run this: mvn test -Dtest=ArticlePageParserTest#testParse org.apache.maven.plugins:maven-surefire-plugin:3.2.2:test org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test. I get:
    [INFO] --- surefire:3.2.2:test (default-test) @ NoTests ---
    [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] --- surefire:2.12.4:test (default-cli) @ NoTests ---
    [INFO] Surefire report directory: /home/matthias/Downloads/NoTests/target/surefire-reports
    
    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running bt.notests.parser.ArticlePageParserTest
    parse
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.042 sec
    
    Results :
    
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
    
  2. pdfbox in version 3.0.1 is broken as it pulls in junit5 onto the compile path

Fixing the pom.xml to this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>bt</groupId>
    <artifactId>NoTests</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!--        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>-->

        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.knowm.xchart</groupId>
            <artifactId>xchart</artifactId>
            <version>3.8.7</version>
        </dependency>
        <dependency>
            <groupId>org.apache.pdfbox</groupId>
            <artifactId>pdfbox</artifactId>
            <version>3.0.2</version>
        </dependency>
    </dependencies>
</project>

Is already enough as surefire 3.x then correctly detects only JUnit4 and invokes the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix Maven [ci] enable "build tools" tests tests
Projects
None yet
Development

No branches or pull requests

3 participants