Search code examples
javajavafxtestfx

TestFX 4: Can't use simply verifyThat(), have to use the whole import name


I suspect there is something weird going on in my project setup. When I try to just use the method verifyThat() the compiler can't find it and I get an error in my program, but when I write out the whole thing, org.loadui.testfx.Assertions.verifyThat(), it works. I am importing like this: import org.loadui.testfx.*;


Solution

  • You probably need to import static (see https://docs.oracle.com/javase/1.5.0/docs/guide/language/static-import.html)

    import static org.loadui.testfx.Assertions.*;
    

    This will import all the public static symbols from the Assertions class, whereas your import only imports the class.

    Assertions.verifyThat()
    

    Should also work in your code.