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

@Parameters cannot use static variable in array #555

Closed
2 of 7 tasks
youming-lin opened this issue Aug 2, 2023 · 3 comments · Fixed by #556
Closed
2 of 7 tasks

@Parameters cannot use static variable in array #555

youming-lin opened this issue Aug 2, 2023 · 3 comments · Fixed by #556

Comments

@youming-lin
Copy link

youming-lin commented Aug 2, 2023

Problem Statement

please read https://github.com/cbeust/testng-eclipse/blob/master/docs/Troubleshooting.md first
Example code:

package test;

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class TestNGEclipseBug {
    private static final String PROPERTY = "property";

    public TestNGEclipseBug() {
        System.setProperty("property", "Hello world!");
    }

    @Parameters({ PROPERTY }) // An internal error occurred during: "Launching TestNGEclipseBug.testBug".
    // @Parameters(PROPERTY) // no error
    // @Parameters({ "property" }) // no error
    // @Parameters("property") // no error
    @Test
    public void testBug(final String property) {
        System.out.println(property);
    }
}

Using @Parameters({ PROPERTY }) would cause error when running the test:
Screenshot 2023-08-02 at 10 21 55 AM

An internal error occurred during: "Launching TestNGEclipseBug.testBug".
class org.eclipse.jdt.core.dom.SimpleName cannot be cast to class org.eclipse.jdt.core.dom.StringLiteral (org.eclipse.jdt.core.dom.SimpleName and org.eclipse.jdt.core.dom.StringLiteral are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @6fa15c7b)

Code compiles, but test cannot run in Eclipse using this plugin. Based on the error message it seems to be issue with Eclipse plugin instead of TestNG itself.

No error if static variable is used by itself (as opposed to wrapped inside array), or if string literal is used instead (array or not).

Similar(same?) issue reported back in 2018: #294 (comment)

Any relate message in "Error Log" view

"Windows -> Show View -> Others -> Error Log"

The Dependency Management tool for your project

  • Maven
  • Gradle
  • Ant
  • Eclipse Buildpath (aka. Use "TestNG Library" for your project in Eclipse)

Operating System

  • Windows
  • Linux
  • OSX
@missedone
Copy link
Collaborator

@youming-lin , thanks for reporting the issue, i can reproduce it with your sample, let me see if i can fix it quickly

@missedone
Copy link
Collaborator

issue fixed, pls update to the latest version 7.8.0.202308061717

@youming-lin
Copy link
Author

@missedone Thank you for fixing this so fast! Downloaded the latest plugin version and I can confirm using static var in array works now.

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

Successfully merging a pull request may close this issue.

2 participants