Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
开发者_开发百科 Improve this questionTesting UI is difficult. What do you think is the best unit testing framework for Swing?
Currently the best in my opinion is FEST.
What do you think is the best unit testing framework for Swing?
Good question. I can't help you with that. I can point you to articles about ui testing I have read from Misko Hevery's site
Misko Hevery's tips
- I would like to point you out to Google's testing guru Misko Hevery's website. He talks a lot about how to write code that is easy to test.
- For example When reading his excellent slides "How to Write Hard to Test Code" he points out at slides 45/288 that the cost of fixing rendering bugs is relatively low. I think that he is right about that and that you should not be to concerned with having 100% code coverage off your UI.
- He also has some good tips to over how to test your UI.
The important thing is to separate the graphical UI from the control logic and data. This can be achieved with the standard Model View Controller design pattern
ObjectMentor
This is a website about testing.I found this interesting article from Michael Featers explaining UI Test Automation Tools are Snake Oil
I have been using Jemmy on top of JUnit. You can see a snippet of their example test-case actions here:
new ClassReference("org.netbeans.jemmy.explorer.GUIBrowser")
.startApplication();
JFrameOperator mainFrame = new JFrameOperator("GUI Browser");
new JButtonOperator(mainFrame, "Reload In").push();
new JLabelOperator(mainFrame, "Reloaded");
JTreeOperator tree = new JTreeOperator(mainFrame);
//click in the middle of the tree
tree.clickMouse();
//collapse node
tree.collapsePath(tree.findPath("", "|"));
//expand node
tree.expandPath(tree.findPath("", "|"));
//select node
tree.selectPath(tree.findPath("GUI Browser", "|"));
JTextFieldOperator testField = new JTextFieldOperator(mainFrame);
//type new value in the text field
testField.clearText();
testField.typeText("3");
精彩评论