#Problems with modules and TestFX.

57 messages · Page 1 of 1 (latest)

spiral thicket
#

Hey there.
I am having some struggles trying to run a test class that is using TestFX. The error I am getting is:

java.lang.RuntimeException: java.lang.IllegalAccessError: class org.testfx.toolkit.impl.ToolkitServiceImpl (in unnamed module @0x1df82230) cannot access class com.sun.javafx.application.ParametersImpl (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.application to unnamed module @0x1df82230... and some more.

If I delete the module-info.java in the main path, the test file will run all good, but I can no longer run the app itself.

Appreciate some explanation to all this modular stuff since all of it is quite new to me.

heady gobletBOT
#

This post has been reserved for your question.

Hey @spiral thicket! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

tidal nexus
#

is testfx a library you are using?

spiral thicket
#

yes, we were given it as a template. I think its correlated to junit if that is for any help:

import org.testfx.framework.junit5.ApplicationTest;
import org.testfx.matcher.control.LabeledMatchers;

tidal nexus
#

it seems like TestFX does not support modules

#

or doesn't support newer versions of JavaFX

#

or both

spiral thicket
#

that does make sense since the provided maven file we were given has versions from 2021

tidal nexus
#

if you want to, you could try updating testfx

spiral thicket
#

how would i approach that?

tidal nexus
#

find the latest version, change it in your pom.xml, reload/update the project

spiral thicket
#

well it seems the latest version were already in use..

#

and javafx is in version 16

tidal nexus
#

Can you run mvn dependency:tree?

#

Does that show you testfx-internal-java9 or testfx-internal-java8?

spiral thicket
#

you gotta help me through that, im very new to this stuff

#

how do i check for what you asked for

spiral thicket
#

i realised yeah ty

tidal nexus
#

you just run mvn dependency:tree in your project directory

spiral thicket
#

yeah sorry i dont know how to do that

tidal nexus
#

What IDE are you using?

spiral thicket
#

vscode

tidal nexus
#

Is Maven installed on your computer?

#

Does VSC have something where it shows you all dependencies?

tidal nexus
spiral thicket
tidal nexus
#

Is testfx-internal-java9 or testfx-internal-java8 in there?

#

maybe you need to expand the testfx-core-... stuff

spiral thicket
#

dont see anything about testfx-internal in the metainf as well

#

hm seems i cant run cause of the terminal

#

maybe i dont got something needed on my pc

spiral thicket
spiral thicket
#

yeah did not have maven installed

#

dependency tree is now running

tidal nexus
spiral thicket
#

dont think so

tidal nexus
#

try adding --add-exports javafx.graphics/com.sun.javafx.application=ALL-UNNAMED to the JVM arguments

#

where running the tests

spiral thicket
#

im sorry to say that the providers of this file already put it in there

spiral thicket
#

in the pom file

tidal nexus
#

now try running all tests with nvn test

spiral thicket
#

yeah thank you that worked

heady gobletBOT
# spiral thicket yeah thank you that worked

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.

spiral thicket
#

seems to just be a vscode issue

#

since it cant run the tests properly with me not deleting the module-info.java file

#

ill close this post then, thank you very much