nus-cs2103-AY2223S2 / forum

12 stars 0 forks source link

Anyone tried to do GUI tests and encountered Illegal Reflective access errors #350

Closed seanfirefox closed 1 year ago

seanfirefox commented 1 year ago

I attempted to use the GUI tests from AB4 and encountered illegal reflective access errors, presumably from testfx.

image

Anyone knows a workaround it? I have tried to set in build.gradle to allow this to pass but without any success.

test {
    useJUnitPlatform()
    finalizedBy jacocoTestReport
    systemProperties = [
            'testfx.robot': 'glass',
            'testfx.headless': 'true',
            'prism.order': 'sw',
            'prism.text': 't2k',
    ]
    jvmArgs = [
            '--add-opens', 'javafx.graphics/javafx.scene=ALL-UNNAMED',
            '--add-opens', 'javafx.controls/javafx.scene.control=ALL-UNNAMED'
    ]
}
seanfirefox commented 1 year ago

Never mind, I have resolved it by upgrading all testfx and monocle dependencies to the latest versions.

damithc commented 1 year ago

Never mind, I have resolved it by upgrading all testfx and monocle dependencies to the latest versions.

Thanks for sharing this, @seanfirefox Could be useful to others attempting to use TestFx.

seanfirefox commented 1 year ago

Just for more sharing, I used testFxVersion 4.0.16-alpha and used the monocle version below.

testImplementation group: 'org.testfx', name: 'openjfx-monocle', version: 'jdk-12.0.1+2'

Also ended up with the below code for my build.gradle.

test {
    useJUnitPlatform()
    finalizedBy jacocoTestReport
    jvmArgs "-Dheadless=${project.hasProperty('headless') ? project.headless : false}"
    systemProperties = [
            'testfx.robot': 'glass',
            'testfx.headless': 'true',
            'prism.order': 'sw',
            'prism.text': 't2k',
    ]
}