Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-dev] How to programmatically uncheck "Create module-info.java" in NewJavaProjectWizardPageOne?

Have you considered using SWTBot[1] or RedDeer[2] for UI testing?

One problem might be that some components are using event rather than calling the getter/setter afterwards.

For SWT Bot it should be something like new SWTBot(<yourdialog>).button("Create module-info.java").click();

[1] https://www.eclipse.org/swtbot/
    https://www.vogella.com/tutorials/SWTBot/article.html
[2] https://projects.eclipse.org/proposals/eclipse-reddeer

Am 09.02.22 um 02:56 schrieb Alexander Kriegisch:
The "new Java project" wizard contains class
NewJavaProjectWizardPageOne. In commit [1], a new checkbox "Create
module-info.java" was added by Kalyan Prasad Tatavarthi. This causes
some trouble in an AspectJ UI test which basically creates a few
projects and verifies something. In doing so, it also sets a few field
values via reflection, because the necessary fields and methods are
private. This is ugly, but it works and is better than copy-pasting the
whole class in order to create a 95% duplicate with some accessible
members.

In our use case, we want to explicitly uncheck the checkbox, because we
do not want to create a modular project. We also want to avoid the
asynchronous pop-up dialogue asking for the module name. Even though
executing the reflective equivalent of

fFirstPage.fModuleGroup.fCreateModuleInfo.setSelection(false);

in the wizard extension used for our test before calling
'super.finishPressed()', the pop-up appears and makes the whole test
suite time out. I tried waiting for 1 up to 10 seconds both before and
after setting the value, which helps on my local Windows workstation but
still seems to be not enough in a GitHub workflow running the same test.
I also tried the reflective equivalent of

fFirstPage.fModuleGroup.fCreateModuleInfo.setSelection(false);
fFirstPage.fModuleGroup.savePreference = true;

to no avail. Actually, I am just trying to fix an old test which works
nicely on Linux and MacOS (maybe by chance). I have no experience
whatsoever with Eclipse UI programming (JFace, SWT) and would welcome
hints about how to reliably and without ugly wait loops uncheck that box
before clicking "Finish" right from wizard page 1.

[1] https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java?id=39b14df0a8be80c7fbc8f9cddab4bf1217626fda



Back to the top