benjamin84 / fest

Automatically exported from code.google.com/p/fest
0 stars 0 forks source link

Better logging when a component cannot be found #71

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From Wim Deblauwe:

'm a bit stuck with my unit test. It runs fine on my pc but on the build
server, it gives an error that a button cannot be found like this:

org.fest.swing.exception.ComponentLookupException:
abbot.finder.ComponentNotFoundException
: No Component found with matcher
'org.fest.swing.fixture.JButtonMatcher@4589eb'
    at org.fest.swing.core.ComponentFinder.find(ComponentFinder.java:256)
    at org.fest.swing.core.ComponentFinder.find(ComponentFinder.java
:241)
    at
org.fest.swing.fixture.JOptionPaneFixture.buttonWithText(JOptionPaneFixture.java
:158)
    at
com.company.UserManagementSetupDialogTest.testChangePasswordAuthenticationWithCa
ncelUponTabChange(UserManagementSetupDialogTest.java
:151)
Caused by: abbot.finder.ComponentNotFoundException: No Component found with
matcher 'org.fest.swing.fixture.JButtonMatcher@4589eb'
    at abbot.finder.BasicFinder.find(BasicFinder.java:87)
    at abbot.finder.BasicFinder.find
(BasicFinder.java:65)
    at org.fest.swing.core.ComponentFinder.find(ComponentFinder.java:254)
    ... 24 more
... Removed 21 stack frames

The problem line is this one:

JOptionPaneFinder.findOptionPane().using( m_window.robot ).buttonWithText(
"Cancel" ).click();

The fix for the JOptionPane you have done might already avoid this problem,
but showing a list of components (buttons in this case) you can "see" would
be very convenient to quickly solve problems like this. Would this be possible?

Original issue reported on code.google.com by Alex.Rui...@gmail.com on 7 Dec 2007 at 1:06

GoogleCodeExporter commented 9 years ago
Hello,

I have had similar problems running on our build farm. The junit tests always 
work 
on my local linux system but SOMETIMES fail (~ 1 out of 10) times on our 
automated 
build system. This intermittant behavior makes FEST unusable for our purposes. 

I am forced to do something like....

http://www.javaworld.com/javaworld/jw-11-2004/jw-1115-swing.html

Just deal with the event dispatch thread and swing instances directly.

Original comment by freaksh...@gmail.com on 12 Dec 2007 at 4:31

GoogleCodeExporter commented 9 years ago
Fixed. The following are the changes made:

When components are not found, the message in the thrown 
ComponentLookupException now
includes list of Components in the hierarchy.

Added methods 'printComponents(PrintStream, Container)' and
'printComponents(PrintStream, Class, Container)' to ComponentFinder.

Added 'toString' implementation to org.fest.swing.core.NameMatcher to facilitate
debugging.

Added 'toString' implementation to org.fest.swing.core.TypeMatcher to facilitate
debugging.

Added 'toString' implementation to org.fest.swing.fixture.JMenuItemMatcher to
facilitate debugging.

Added 'toString' implementation to org.fest.swing.fixture.JButtonMatcher to
facilitate debugging.

Original comment by Alex.Rui...@gmail.com on 21 Dec 2007 at 1:25

GoogleCodeExporter commented 9 years ago
The following is an example of how ComponentLookupException includes the 
component
hierarchy: 

org.fest.swing.exception.ComponentLookupException: Unable to find component 
using
matcher org.fest.swing.core.NameMatcher[name='list'].
Component hierarchy:
javax.swing.JPanel<'null.glassPane'>
javax.swing.JButton<'button'>
javax.swing.JPanel<'null.contentPane'>
javax.swing.JLayeredPane<'null.layeredPane'>
javax.swing.JRootPane[,4,23,104x33,layout=javax.swing.JRootPane$RootLayout,align
mentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,prefer
redSize=]
org.fest.swing.core.ComponentFinderTest$MainWindow<'frame1'>

    at org.fest.swing.core.ComponentFinder.componentNotFound(ComponentFinder.java:274)
    at org.fest.swing.core.ComponentFinder.find(ComponentFinder.java:268)
    at org.fest.swing.core.ComponentFinder.findByName(ComponentFinder.java:239)
    at org.fest.swing.core.ComponentFinder.findByName(ComponentFinder.java:213)

Original comment by Alex.Rui...@gmail.com on 21 Dec 2007 at 1:26

GoogleCodeExporter commented 9 years ago
Set the module as a label, instead of being part of the title.

Original comment by Alex.Rui...@gmail.com on 1 Dec 2008 at 1:40