Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Challenges with Unit Testing (Application, Component Events)
Hi,
For a while I'm trying to implement unit tests for my UI (with Vaadin). More or less I'm following Passive View pattern for this task. I did not choose the most idealistic solution which would be isolating the UI completely by wrappers and adapters but still I'm using Powermock's WhiteBox for some reflection based work such as invoking the "fireClick" of button.
I had some challenges apart from basic event invocations (such as in button) and I'd like to have your opinion for improved solutions :
1. Since I could not find a way to access and use AbstractComponents' fireEvent(Component.Event event) method from the bottom of the hierarchy via reflection. As a result, I opted to convert lots of things to Buttons which styled as link.
Do you know any way of firing events like double click on a Embedded let's say.
2. (Related to first one) Since I started to use buttons, I started to use icons as well and feeding them with some images. When it has to be done in the constructor it becomes a problem because all the Resource based operations requires an Application object and in unit test we don't have it (tell me if I'm wrong). So far I'm injecting an Application mock object but then I have to move all icon change or resource based operations from constructors since I can only inject the member after object is constructed. Therefore it creates a scenario where I'm creating explicit methods that should be called after the construction is done. It's not so bad but is there a way to avoid it ?
Cheers !
Ozgun