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

Add Junit-Jupiter support #265

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wjbakker
Copy link

@wjbakker wjbakker commented Jan 8, 2022

Adds a Junit-Jupiter Extension for tests annotated with @GUITest.

Tests can now be run with the @GUITestExtension.

A new module is added:

<dependency>
  <groupId>org.assertj</groupId>
  <artifactId>assertj-swing-junit-jupiter</artifactId>
</dependency>

Example usage:

@ExtendWith(GUITestExtension.class)
class MyGuiTest {
  (...)
}

Solves !259

Adds a Junit-Jupiter Extension for tests annotated with @GUITest.
@gschrader
Copy link
Contributor

gschrader commented Apr 12, 2022

I'm not sure if you're still using AssertJSwingTestCaseTemplate for your tests but I found that tests would hang if you had an exception in any @BeforeEach or @AfterEach. I worked around that (I think) using this extension:

@RegisterExtension
InvocationInterceptor invocationInterceptor = new InvocationInterceptor() {
    @Override
    public void interceptBeforeEachMethod(InvocationInterceptor.Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
        proceedWithRobotCleanup(invocation);
    }


  @Override
    public void interceptAfterEachMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
        proceedWithRobotCleanup(invocation);
    }


    private void proceedWithRobotCleanup(Invocation<Void> invocation) throws Throwable {
        try {
            invocation.proceed();
        } catch (Throwable e) {
            if (robot() != null) {
                cleanUp();
            }
            throw e;
        }
    }
};

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

Successfully merging this pull request may close these issues.

2 participants