GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [test] kotest logs look broken · Issue #4236 · pmd/pmd

[test] kotest logs look broken #4236

New issue
Copy link
New issue
Copy link
Closed
#4346
pmd/build-tools
#27
pmd/build-tools#27
Closed
[test] kotest logs look broken#4236
#4346
pmd/build-tools
#27
Copy link
Assignees
adangel
Labels
a:bugPMD crashes or fails to analyse a file.in:testingAbout tests of pmd, eg the module pmd-lang-test or pmd-test [test]
Milestone
6.54.0

Description

@oowekyala
oowekyala
opened on Nov 26, 2022
Issue body actions

Since #4173 the maven logs of kotest tests look really weird:

FO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 s - in net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Running net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Running net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 s - in net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.011 s - in net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Running net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Running net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 s - in net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 s - in net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Running net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Running net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 s - in net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 s - in net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Running net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Running net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.019 s - in net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 s - in net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Running net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest
[INFO] Running net.sourceforge.pmd.lang.java.symbols.table.internal.HeaderScopesTest

It seems tests are not aggregated anymore under a single header. I'm not sure if there's something we're doing wrong in our kotest integration, or if it's a regression in kotest itself...

Activity

  1. oowekyala
    added
    a:bugPMD crashes or fails to analyse a file.
    in:testingAbout tests of pmd, eg the module pmd-lang-test or pmd-test [test]
    on Nov 26, 2022
  2. adangel
    added this to the 6.54.0 milestone on Jan 19, 2023
  3. adangel
    self-assigned this
    on Jan 19, 2023
  4. adangel commented on Jan 19, 2023

    @adangel
    adangel
    on Jan 19, 2023
    Member
    More actions

    Hm... I haven't figured it out yet.
    There is a bugfix in surefire plugin https://issues.apache.org/jira/browse/SUREFIRE-2101 which might be relevant - fixed in 3.0.0-M8.
    We can also configure https://github.com/fabriciorby/maven-surefire-junit5-tree-reporter

    If I do this, it looks like this:

    $ ./mvnw test -pl pmd-java -Dtest=Java15KotlinTest
    ...
    [INFO] --- maven-surefire-plugin:3.0.0-M8:test (default-cli) @ pmd-java ---
    [INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
    [INFO] 
    [INFO] -------------------------------------------------------
    [INFO]  T E S T S
    [INFO] -------------------------------------------------------
    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 15 '""" <html> <body> <p>Hello, world</p> </body> </html> """' - 0.108s
    [INFO] │  └─ ✔ null - 0.098s
    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 16 '""" <html> <body> <p>Hello, world</p> </body> </html> """' - 0.007s
    [INFO] │  └─ ✔ null - 0.003s
    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 17 '""" <html> <body> <p>Hello, world</p> </body> </html> """' - 0.007s
    [INFO] │  └─ ✔ null - 0.004s
    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 18 '""" <html> <body> <p>Hello, world</p> </body> </html> """' - 0.009s
    [INFO] │  └─ ✔ null - 0.003s
    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 18-preview '""" <html> <body> <p>Hello, world</p> </body> </html> """' - 0.013s
    [INFO] │  └─ ✔ null - 0.01s
    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 19 '""" <html> <body> <p>Hello, world</p> </body> </html> """' - 0.011s
    [INFO] │  └─ ✔ null - 0.006s
    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 19-preview '""" <html> <body> <p>Hello, world</p> </body> </html> """' - 0.016s
    [INFO] │  └─ ✔ null - 0.008s
    [INFO] 
    

    The test names end up in the class names and the test name is null.

    When creating a `FunSpec` based test

    /*
     * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
     */
    
    package net.sourceforge.pmd.lang.java.ast
    
    import io.kotest.core.spec.style.FunSpec
    import io.kotest.matchers.shouldBe
    
    class FunSpecTest : FunSpec({
        context("group 1") {
            test("my first test") {
                1 + 2 shouldBe 3
            }
            test("another test") {
                2 + 2 shouldBe 4
            }
        }
        context("group 2") {
            test("3rd test") {
                1 + 2 shouldBe 3
            }
        }
    })

    The three test cases are also not really grouped correctly and also don't have test names:

    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.FunSpecTest group 1 my first test - 0.049s
    [INFO] │  ├─ ✔ null - 0.025s
    [INFO] │  └─ ✔ null - 0.002s
    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.FunSpecTest group 2 3rd test - 0.01s
    [INFO] │  └─ ✔ null - 0.001s
    

    I guess the problem is somewhere in our ParserTestSpec, in Kotest and in Surefire...

  5. adangel commented on Jan 20, 2023

    @adangel
    adangel
    on Jan 20, 2023
    Member
    More actions

    Ok, so here is what happens: Surefire doesn't really support nested test sets (similar to gradle obviously, see https://kotest.io/docs/framework/test_output.html). That is, surefire reacts on each test set start (that's when Running net.sf.pmd.... is printed) and on each test set complete event (that's when the summary is printed like Tests run: 5, Failures: 0, ...).

    When we have nested test sets, which happens easily with our kotest based parser tests, then we might have test sets without any tests in it - but with other nested test sets. Such test sets without tests are called container nodes, and the actual test cases are in the leaf nodes of the test plan tree.

    That's how the following needs to be interpreted:

    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest   <---- that's the outermost test set
    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest   <---- nested level 1: "textBlocks"
    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest   <---- nested level 2: "Java 15"
    [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 s - in net.sourceforge.pmd.lang.java.ast.Java15KotlinTest <--- finished "Java 15"
    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest   <---- nested level 2: "Java 16"
    [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 s - in  net.sourceforge.pmd.lang.java.ast.Java15KotlinTest <--- finished "Java 16"
    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest   <---- nested level 2: "Java 17"
    [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.011 s - in net.sourceforge.pmd.lang.java.ast.Java15KotlinTest <--- finished "Java 17"
    [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.08 s - in net.sourceforge.pmd.lang.java.ast.Java15KotlinTest <--- finished "textBlocks"
    [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.087 s - in net.sourceforge.pmd.lang.java.ast.Java15KotlinTest <--- finished outermost test set
    

    The actual test names from Kotest are not delivered as "Method Name" - since there are no real methods behind these test cases. Kotest delivers the full name however in a similar way, how JUnit5 @DisplayName will deliver it to surefire. And that's what the documentation Surefire Extensions and Reports Configuration for @DisplayName. In surefire, these "custom" names are called "phrased" class name etc.

    This can be enabled, then the output will look like this:

    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest
    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks
    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 15
    [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.014 s - in net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 15
    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 16
    [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 s - in net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 16
    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 17
    [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 s - in net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 17
    [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.062 s - in net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks
    [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.07 s - in net.sourceforge.pmd.lang.java.ast.Java15KotlinTest
    

    So the data is there, but it's still presented, as if these would be totally different test cases.

    Using the mentioned Maven Surefire JUnit5 TreeView Extension gives this output:

    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 15 '""" <html> <body> <p>Hello, world</p> </body> </html> """' - 0.013s
    [INFO] │  └─ ✔ null - 0.011s
    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 16 '""" <html> <body> <p>Hello, world</p> </body> </html> """' - 0.005s
    [INFO] │  └─ ✔ null - 0.003s
    [INFO] ├─ net.sourceforge.pmd.lang.java.ast.Java15KotlinTest textBlocks Java 17 '""" <html> <body> <p>Hello, world</p> </body> </html> """' - 0.004s
    [INFO] │  └─ ✔ null - 0.003s
    

    This also prints out the full test case name, but also a weird "null". The testset name is the full test case name, and then the test case name is missing.
    Also, this reporter doesn't render a summary, which I think is nice to know: How many tests have been executed in the test case, etc.

    That's why I created an own console reporter (pmd/build-tools#27). The output with that is this:

    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest
    [INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.866 s - in net.sourceforge.pmd.lang.java.ast.Java15KotlinTest
    

    It collects all test sets that belong to the same test class.
    Failing test cases are directly logged, e.g.

    [INFO] Running net.sourceforge.pmd.lang.java.ast.ASTPatternTest
    [INFO]     └─ Test patterns only available on JDK16 or higher (including preview)
    [INFO]         └─ Java 1.3
    [INFO]             └─ ✘ [unnamed test case]
    

    You could enable to log also the successful tests, e.g.

    [INFO] Running net.sourceforge.pmd.lang.java.ast.Java15KotlinTest
    [INFO]     └─ textBlocks
    [INFO]         └─ Java 15
    [INFO]             └─ ✔  '""" <html> <body> <p>Hello, world</p> </body> </html> """'
    [INFO]     └─ textBlocks
    [INFO]         └─ Java 16
    [INFO]             └─ ✔  '""" <html> <body> <p>Hello, world</p> </body> </html> """'
    [INFO]     └─ textBlocks
    [INFO]         └─ Java 17
    [INFO]             └─ ✔  '""" <html> <body> <p>Hello, world</p> </body> </html> """'
    ...
    [INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.196 s - in net.sourceforge.pmd.lang.java.ast.Java15KotlinTest
    

    But I think, we should leave this option off.

    I'm going to create a PR to update master to use this new console reporter.

  6. adangel
    closed this as completedin build-tools#27on Jan 20, 2023
  7. adangel
    reopened this on Jan 20, 2023
  8. jsotuyod
    closed this as completedin #4346on Jan 24, 2023
  9. adangel
    added a commit that references this issue on Jan 25, 2023

    [doc] Update release notes (#4236)

    599e0b6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @adangel
    adangel

Labels

a:bugPMD crashes or fails to analyse a file.in:testingAbout tests of pmd, eg the module pmd-lang-test or pmd-test [test]

Type

No type

Projects

No projects

    Milestone

    • 6.54.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.