Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reusing the framefixture for multiple tests #44

Closed
eitzenbe opened this issue Oct 24, 2018 · 2 comments
Closed

Reusing the framefixture for multiple tests #44

eitzenbe opened this issue Oct 24, 2018 · 2 comments

Comments

@eitzenbe
Copy link

Hi,
I really like assertJ's swing module but found it impossible
to like instantiate the FrameFixture ONCE per class and run a few tests on the same frame fixture,
as the robot gets cleaned up after each test method. Any way of achieving this ?

br
Thomas

@eitzenbe
Copy link
Author

Answering my own question ;)

package org.et.mmplayer;

import org.assertj.swing.core.BasicRobot;
import org.assertj.swing.core.Robot;
import org.assertj.swing.dependency.jsr305.Nonnull;
import org.assertj.swing.edt.FailOnThreadViolationRepaintManager;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;

public class BasicSwingTestcase {
private static Robot robo;

public BasicSwingTestcase() {
}

@BeforeClass
public static final void setUpOnce() {
  if (robo == null) {
    robo = BasicRobot.robotWithNewAwtHierarchy();
  }
  FailOnThreadViolationRepaintManager.install();
}

@Before
public final void setUp() {
  this.onSetUp();
}

protected void onSetUp() {};

@AfterClass
public static final void tearDownOnce() {
  robo.cleanUp();
  FailOnThreadViolationRepaintManager.uninstall();
}

@After
public final void tearDown() {
    this.onTearDown();
}

protected void onTearDown() {
}

/**

  • @return this test's {@link Robot}
    */
    protected static final @nonnull Robot robot() {
    return robo;
    }

}

Easier then expected

@PascalSchumacher
Copy link
Member

I'm closing this because assertj-swing issues should be reported at: https://github.com/joel-costigliola/assertj-swing/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants