Two Laptop Bag
The moose likes Testing and the fly likes About JUnit with GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "About JUnit with GUI" Watch "About JUnit with GUI" New topic

About JUnit with GUI

Mikey Chen

Joined: Jul 12, 2002
Posts: 29
I am program with swing. But I don't know how to use JUnit with it.
I want to use this way for unit test.
All logical code will be sperate with swing and the swing only to present the data. So use the JUnit to test the logical code, the UI will not be test by JUnit.
Does it a good way?
Do you have any Unit test experience with JUnit, will you share it to me?

Rome was not built in a day.
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
Yes, it's a good idea to write your code so that testing the logic doesn't require going through Swing components.
However, if you want to (or, for some parts of your application, have to) test your Swing components as well, consider using JFCUnit for the job.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Mikey Chen

Joined: Jul 12, 2002
Posts: 29
Lasse Koskela:
Now I have downloaded the JFCUnit.
I will add it in my work.
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Also take a look at

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: About JUnit with GUI
jQuery in Action, 3rd edition