-
Notifications
You must be signed in to change notification settings - Fork 184
Add a SWTTest Junit extension to allow tests executed in the UI thread #2624
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
base: master
Are you sure you want to change the base?
Conversation
This currently is just a proof-of-concept on how we can make testing more self-contained. One likely more wants to use an Other annotation might be used to drive the event-queue automatically after each test. so a "typical" SWT test then can look like this:
|
Currently we require SWT-UI based tests to be executed by special runners known as the 'UIHarness' to be run in the UI thread, what has several problems: 1) is requires usually to fire up a whole workbench (and a workspace) 2) the whole testsuite has to run in the UI thread 3) no way to customize this further 4) actually this is nothing that belongs into the test framework This now adds a new SWTTest JUnit extension that allows to mark a test class with an extension and get your methods executed in the UI thread.
d41f3cb
to
1337680
Compare
That reminds me of https://bugs.eclipse.org/bugs/show_bug.cgi?id=548970 ;) |
Any coincidence is only random :-P
I really like to go in that direction because it shifts responsibility from Tycho (where it does not belong to), to the actual "library" (SWT/Platform) what is a much better fit. I'm just noch sure where to best place such code:
We already have Of course one might also start with something "fresh" but where should it be located? Tycho? Platform? and own project? |
I didn't think that org.eclipse.test was meant to be "API" used outside of the Platform's own builds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this added on SWT production code, not in SWT tests?
Eclipse usually does not mix production & test code in one bundle / source directory.
public void interceptTestMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, | ||
ExtensionContext extensionContext) throws Throwable { | ||
|
||
if (Display.getCurrent() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be Display.getCurrent() != null
?
Because it is not test code but something you will need to use in production see:
|
While those are generic about SWT, I suggest we add such code to org.eclipse.ui.tests.harness, which is often used as a test depedency and provides the widely used |
The place do not matter much to me unless it:
|
Currently we require SWT-UI based tests to be executed by special runners known as the 'UIHarness' to be run in the UI thread, what has several problems:
This now adds a new SWTTest JUnit extension that allows to mark a test class with an extension and get your methods executed in the UI thread.