package main; import org.fest.swing.core.Robot; import org.fest.swing.core.RobotFixture; import org.fest.swing.fixture.FrameFixture; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; public class TestMenuItemWithPath { protected static Robot robot; protected static FrameFixture frame; @BeforeClass public static void setUp() { // create FEST robot robot = RobotFixture.robotWithCurrentAwtHierarchy(); // create fixture for main frame frame = new FrameFixture(robot, ApplicationFrame.getInstance()); } /** * Tests the expected behavior of {@link FrameFixture#menuItemWithPath(String...)}. */ @Test(expected = Throwable.class) public void willFail() { // "Item 1" doesn't exist before the call to menuItemWithPath, so it doesn't find it frame.menuItemWithPath("Menu", "Item 1").click(); } /** * Works around the problem with {@link FrameFixture#menuItemWithPath(String...)}. */ @Test public void willPass() { // click "Menu", which creates "Item 1" frame.menuItemWithPath("Menu").click(); // click "Item 1" frame.menuItemWithPath("Menu", "Item 1").click(); } @AfterClass public static void tearDown() { robot.cleanUp(); } }