One minute starting guide

Assuming you have only little time, here's the quickest introduction to AssertJ Swing. Depending on your reading and coding skills, this should be done in about one minute. ☺

AssertJ Swing artifacts are in Maven central repository. There are two main artifacts: assertj-swing-testng and assertj-swing-junit.

It should be obvious that JUnit users should depend on assertj-swing-junit while TestNG users should depend on assertj-swing-testng ;-)





If you use another dependency tool, please check this page to find the relevant AssertJ Swing dependency declaration for your tool.

JIDE support (optional)

For adding the JIDE dependent features you have to add assertj-swing-jide additionally to the libraries for your test framework. Note that this step is only required for users of JIDE, else it is optional!


Make some static imports

import static org.assertj.swing.launcher.ApplicationLauncher.application;
import static org.assertj.swing.finder.WindowFinder.findFrame;

extend our base test case,

// either for JUnit
// or for TestNG

and add the following to the onSetUp() method to start your application via its main method.

// without arguments
// with arguments

Then you just need to tell AssertJ Swing to find the main frame of your application and start testing:

FrameFixture frame = findFrame(new GenericTypeMatcher<Frame>(Frame.class) {
  protected boolean isMatching(Frame frame) {
    return "Your application title".equals(frame.getTitle()) && frame.isShowing();

Now frame refers to the test fixture for your main frame and you're ready to test it.

Type frame. and your IDE will show you the available commands. Assuming your frame contains a table that should have 42 rows you could for instance write:


That's all!

See our more detailed getting started guide to get the maximum out of it!

You can learn more by looking at AssertJ Swing javadoc.

Another way is to go see assertj-examples, it covers what is possible with AssertJ and contains projects for AssertJ Swing, too. You can clone it and run its tests!