This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

JUnit tests with GUI

General questions regarding the development with JVx.

JUnit tests with GUI

Postby jvxdev » Mon Mar 07, 2016 4:00 pm

How do I start a JVx application for JUnit tests?

I tried to start the application with a custom launcher, but got a NullPointerException. Do you have a special launcher for JUnit tests?
Posts: 19
Joined: Fri Mar 04, 2016 12:40 pm

Re: JUnit tests with GUI

Postby Support@SIB » Mon Mar 07, 2016 4:15 pm

What do you mean with "a custom launcher". Did you extend an existing launcher or create a new one?

It's not necessary to create a new launcher. Simply use an existing one.

If you want to start the whole application, you could do following:

Syntax: [ Download ] [ Hide ]
SwingApplication app = new SwingApplication();
app.startup(YourApplication.class.getName(), "/yourapp/application.xml", null);
while (app.getApplication() == null || !app.getApplication().getLauncher().isVisible())
    catch (InterruptedException ie)
        throw new RuntimeException(ie);
YourApplication yapp = (YourApplication)app.getApplication();

if (yapp == null)
{"Application was not started!");

If you won't start the whole application, it's important to set at least a factory:

Syntax: [ Download ] [ Hide ]

The factory is important if you want to use GUI classes in your test cases. See example JUnit test-case.

If your test cases don't work because of invalid configuration files, it could help to set the configuration basedir:

Syntax: [ Download ] [ Hide ]
System.setProperty(IPackageSetup.CONFIG_BASEDIR, new File("").getAbsolutePath());

The path should be the directory which contains the rad directory.

Another option for headless tests is the JVx headless UI.
User avatar
Posts: 353
Joined: Mon Sep 28, 2009 1:56 pm

Re: JUnit tests with GUI

Postby Development@SIB » Thu Aug 25, 2016 1:19 pm

A complete launcher implementation is available here. The SimpleTestLauncher class.
User avatar
Posts: 325
Joined: Mon Sep 28, 2009 1:54 pm

Return to Development