DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. How to Use Jemmy with JUnit in NetBeans IDE

How to Use Jemmy with JUnit in NetBeans IDE

Lyndon Armitage user avatar by
Lyndon Armitage
·
Dec. 05, 12 · Interview
Like (0)
Save
Tweet
Share
6.62K Views

Join the DZone community and get the full member experience.

Join For Free

we are always constantly looking to improve and refine our testing. currently we are looking into improving our tests for forms in our pdf viewer.

for the gui testing we are using jemmy , a library that comes with the netbeans ide and is very useful for testing swing applications. netbeans also comes with junit bundled in for unit testing that we also make use of. if you are writing a module and want to use jemmy this is a good place to start. however if you want to use jemmy with a project as opposed to a module you will need to remember to add it to the classpath.

so we wanted to have our jemmy tests run as part of our unit testing but there wasn't much in the way of documentation on how to do this.

upon investigation it is actually very easy to get them working together. what you need to do is simply write junit tests that utilize jemmy so for example:

@test
public void junittest() {
jframeoperator mainframe = new jframeoperator();
jtextfieldoperator textfield = new jtextfieldoperator(mainframe, "textin");
int x = 10;
assertequals(x, textfield.getlocationonscreen().x);
}

adding the @test annotation and making use of junit's assertequals() and fail() if needed.

and that's pretty much it!


one thing worth mentioning is that when reading/writing text files for loading test data it's important to make sure you explicitly set the encoding. as i found that when running jemmy as a standalone test, not using the test option in netbeans and not as part of a junit test, it used a different default encoding to when using the test option and running it as part of our unit testing.

what methods do you use to improve your testing?

Integrated development environment JUnit NetBeans unit test

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Beginners’ Guide to Run a Linux Server Securely
  • The Importance of Delegation in Management Teams
  • Asynchronous HTTP Requests With RxJava
  • Kotlin Is More Fun Than Java And This Is a Big Deal

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: