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

Test class name missing (unnamed) #919

Open
wirdman opened this issue Aug 18, 2023 · 6 comments
Open

Test class name missing (unnamed) #919

wirdman opened this issue Aug 18, 2023 · 6 comments
Labels

Comments

@wirdman
Copy link

wirdman commented Aug 18, 2023

Jenkins and plugins versions report

Environment
Jenkins: 2.387.3
OS: Linux - 3.10.0-1160.92.1.el7.x86_64
Java: 11.0.19 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
ace-editor:1.1
active-directory:2.25
allure-jenkins-plugin:2.29.0
analysis-core:1.95
ansicolor:1.0.2
ant:1.11
antisamy-markup-formatter:2.1
apache-httpcomponents-client-4-api:4.5.14-150.v7a_b_9d17134a_5
artifactory:3.13.2
async-http-client:1.9.40.0
audit-trail:3.10
badge:1.9.1
bootstrap4-api:4.6.0-3
bootstrap5-api:5.3.0-1
bouncycastle-api:2.28
branch-api:2.7.0
browserstack-integration:1.2.3
build-blocker-plugin:1.7.7
build-failure-analyzer:2.4.1
build-monitor-plugin:1.14-717.v3efcdffe8d58
build-name-setter:2.2.0
build-timeout:1.20
build-user-vars-plugin:1.8
build-with-parameters:1.5.1
buildresult-trigger:0.17
built-on-column:1.1
caffeine-api:2.9.3-65.v6a_47d0f4d1fe
checks-api:2.0.0
cloudbees-folder:6.815.v0dd5a_cb_40e0e
cloverphp:0.6
cobertura:1.16
code-coverage-api:1.4.1
command-launcher:90.v669d7ccb_7c31
commons-lang3-api:3.12.0-36.vd97de6465d5b_
commons-text-api:1.10.0-36.vc008c8fcda_7b_
conditional-buildstep:1.4.1
config-file-provider:938.ve2b_8a_591c596
copy-to-slave:1.4.4
copyartifact:1.46.2
credentials:1254.vb_96f366e7b_a_d
credentials-binding:604.vb_64480b_c56ca_
cucumber-reports:5.6.0
custom-tools-plugin:0.8
data-tables-api:1.11.2-1
date-parameter:0.0.4
dependency-check-jenkins-plugin:5.1.1
deployed-on-column:1.8
deployer-framework:1.3
display-url-api:2.3.7
dropdown-viewstabbar-plugin:1.7
durable-task:1.39
dynamicparameter:0.2.0
echarts-api:5.4.0-5
email-ext:2.83
embeddable-build-status:2.0.3
envinject:2.4.0
envinject-api:1.8
extended-choice-parameter:0.82
extended-read-permission:3.2
external-monitor-job:1.7
flaky-test-handler:1.2.0
font-awesome-api:6.4.0-1
forensics-api:1.4.0
fortifyJenkins:1.4.21
fstrigger:0.41
generic-webhook-trigger:1.86.5
ghprb:1.42.2
git:5.1.0
git-client:4.4.0
git-parameter:0.9.18
git-server:1.10
github:1.34.1
github-api:1.133
gitlab-plugin:1.5.12
golang:1.4
gradle:1.37.1
grails:1.7
greenballs:1.15.1
groovy:2.4
groovy-postbuild:2.5
hashicorp-vault-plugin:2.1.1
hidden-parameter:0.0.4
hockeyapp:1.5.0
htmlpublisher:1.25
instance-identity:173.va_37c494ec4e5
ionicons-api:56.v1b_1c8c49374e
ivy:2.1
ivytrigger:0.35
jackson2-api:2.15.2-350.v0c2f3f8fc595
jacoco:3.3.0
jakarta-activation-api:2.0.1-3
jakarta-mail-api:2.0.1-3
javadoc:1.6
javax-activation-api:1.2.0-6
javax-mail-api:1.6.2-8
jaxb:2.3.8-1
jdk-tool:1.5
jenkins-multijob-plugin:1.36
jenkinswalldisplay:0.6.34
job-import-plugin:3.6
jobConfigHistory:2.28.1
jquery:1.12.4-1
jquery-detached:1.2.1
jquery3-api:3.7.0-1
jsch:0.1.55.2
junit:1214.va_2f9db_3e6de0
ldap:2.7
logfilesizechecker:1.5
m2release:0.16.2
mailer:457.v3f72cb_e015e5
mapdb-api:1.0.9.0
mask-passwords:3.3
matrix-auth:3.1.8
matrix-project:789.v57a_725b_63c79
matrix-reloaded:1.1.3
maven-plugin:3.13
metrics:4.2.18-439.v86a_20b_a_8318b_
mina-sshd-api-common:2.10.0-69.v28e3e36d18eb_
mina-sshd-api-core:2.10.0-69.v28e3e36d18eb_
monitoring:1.88.0
msbuild:1.30
mstest:1.0.0
multiple-scms:0.8
naginator:1.18.1
next-build-number:1.7
nodejs:1.4.0
nodelabelparameter:1.9.2
okhttp-api:3.14.9
pam-auth:1.6
parameter-separator:1.3
parameterized-scheduler:1.0
parameterized-trigger:2.45
performance:3.20
plain-credentials:143.v1b_df8b_d3b_e48
plot:2.1.9
plugin-usage-plugin:4.0
plugin-util-api:3.3.0
popper-api:1.16.1-2
popper2-api:2.10.1-1
port-allocator:1.8
postbuild-task:1.9
powershell:1.6
promoted-builds:892.vd6219fc0a_efb
rebuild:320.v5a_0933a_e7d61
release:2.11
resource-disposer:0.16
role-strategy:3.2.0
run-condition:1.5
sbt:1.5
scm-api:676.v886669a_199a_a_
scoverage:1.4.0
script-security:1251.vfe552ed55f8d
scriptler:3.3
scripttrigger:0.34
sectioned-view:1.25
secure-requester-whitelist:1.6
show-build-parameters:1.0
skip-certificate-check:1.0
slack:999999-SNAPSHOT (private-143253a3-iaroic2)
slack-uploader:1.7
snakeyaml-api:1.33-95.va_b_a_e3e47b_fa_4
sonar:2.13.1
ssh-agent:1.23
ssh-credentials:305.v8f4381501156
sshd:3.237.v883d165a_c1d3
structs:324.va_f5d6774f3a_d
swarm:3.28
test-results-analyzer:0.3.5
testng-plugin:1.15
text-finder:1.16
timestamper:1.13
token-macro:359.vb_cde11682e0c
translation:1.16
trilead-api:2.84.v72119de229b_7
twistlock-jenkins-plugin:18_11_96
uno-choice:2.5.6
urltrigger:0.49
validating-string-parameter:2.8
variant:59.vf075fe829ccb
vault_pki_plugin:1.0-SNAPSHOT (private-eba358b8-jenkins)
windows-slaves:1.8
workflow-api:1215.v2b_ee3e1b_dd39
workflow-basic-steps:2.24
workflow-cps:3697.vb_470e454c232
workflow-cps-global-lib:2.21
workflow-durable-task-step:2.40
workflow-job:1308.v58d48a_763b_31
workflow-multibranch:2.26
workflow-scm-step:415.v434365564324
workflow-step-api:639.v6eca_cd8c04a_a_
workflow-support:839.v35e2736cfd5c
ws-cleanup:0.39
xtrigger:0.54

What Operating System are you using (both controller, and any agents involved in the problem)?

Linux

Reproduction steps

  1. Build any job with the plugin enabled.

Expected Results

See class names prefixing the test names

Actual Results

website_tests - #172 Still Failing after 9 min 50 sec (Open)
Test Status:
Passed: 764, Failed: 2, Skipped: 2
2 Failed Tests:
unnamed.checkFocusOnEligibleGamesIosLessThan7 after 0 ms
unnamed.testEligibleGamesForLoggedIn after 0 ms

Anything else?

We were using an older version of this plugin 2.49 and after upgrading to the latest version we noticed that the class name is missing or rather replaced by unnamed which isn't very helpful in debugging tests.

Any info/hints/help would be greatly appreciated.

Thanks.

@wirdman wirdman added the bug label Aug 18, 2023
@timja
Copy link
Member

timja commented Aug 18, 2023

No idea please provide a minimal reproduction.

@wirdman
Copy link
Author

wirdman commented Aug 18, 2023

Even when running jenkins locally (mac) via the mvn hpi:run command with a simple spring boot project I get the following slack notifications:

test_slack - #3 Started by user anonymous ([Open](http://localhost:8080/jenkins/job/test_slack/3/display/redirect))
[13:56] test_slack - #3 Failure after 14 sec ([Open](http://localhost:8080/jenkins/job/test_slack/3/display/redirect))
No Tests found.

First one when job starts and second when it finishes. Apparently it cannot find the tests this time even though they are run via mvn clean install and I can see the failed tests in the jenkins job console output.

With the previous example the tests are somehow seen but the class name is missing (unnamed is returned by the getTestClassAndMethod method for the class name).

I'm not sure if this has anything to do with some java/mvn/junit plugin but the action AbstractTestResultAction<?> action = this.build.getAction(AbstractTestResultAction.class); definitely doesn't have the right information.

@timja
Copy link
Member

timja commented Aug 18, 2023

Yes it’s the junit plugin which returns this. If you search the code it does it when a parent is missing

@wirdman
Copy link
Author

wirdman commented Aug 18, 2023

Understood, I'll try to dig into that plugin a bit. I did notice that the action was from the hudson package but thought there might be something more. Thanks, will get back if I get to the bottom of this. Is there a "compatibility matrix" between the junit and this plugin?

@timja
Copy link
Member

timja commented Aug 18, 2023

Is there a "compatibility matrix" between the junit and this plugin?

Only latest and latest are tested and expected to work together.
Others should work but are not tested.

@wirdman
Copy link
Author

wirdman commented Aug 21, 2023

After spending too much time on this I finally got to the bottom of it (ish). We are using (for some jobs) the testng plugin for test reports. For some reason since upgrading our jenkins instance and this plugin the TestResult result no longer had the className populated. I've debugged and changed a bit this method:


private String getTestClassAndMethod(TestResult result) {
            String fullDisplayName = result.getFullDisplayName();

            if (fullDisplayName.contains("unnamed.")) {
                return ((CaseResult) result).getClassName() + "." + result.getName();
            }
            if (StringUtils.countMatches(fullDisplayName, ".") > 1) {
                int methodDotIndex = fullDisplayName.lastIndexOf('.');
                int testClassDotIndex = fullDisplayName.substring(0, methodDotIndex).lastIndexOf('.');

                return fullDisplayName.substring(testClassDotIndex + 1);

            } else {
                return fullDisplayName;
            }
        }

I'm pretty sure the fullDisplayName.contains("unnamed.") check is a code smell, however the ((CaseResult) result).getClassName() + "." + result.getName(); works to add the class name back to the test name.

If you think this would be useful as a PR - I can add it. If not maybe you have some idea of how to fix this in a better way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants