| By Satadip Dutta | Article Rating: |
|
| July 18, 2009 12:45 PM EDT | Reads: |
40,122 |
In this scenario, the GUI tasks have been identified and the specification is ready to be coded. A good way to begin coding is to write the tests that need to be passed before the GUI is created. The XML-based scripts can be used to create different test cases; however, to demonstrate the full power of Abbot, this section will discuss how the JUnit test cases can be written for the GUI.
The Abbot Java API will be used to write traditional JUnit test cases. The salient features of the API that help in creating test cases are:
The Celsius-to-Fahrenheit converter example presented in the previous section is used to walk through the steps involved in creating a test case using the Abbot Java API. In this test case, the input of a negative number to the Celsius input will be tested.
Like JUnit test cases, the CelsiusConverterTest class will subclass the junit.Framework.TestCase class and the constructor will initialize the name of the test.
public class CelsiusConverterTest
extends TestCase {
public CelsiusConverterTest
(String name) { super(name); }
}
The setUp() and tearDown() methods can be used to initialize the frame in which the GUI will run. The setUp() method may be used to populate any arrays or other defaults that are required by the GUI to be fully functional.
private ComponentTester tester;
protected void setUp() {
tester =
ComponentTester.getTester
(CelsiusConverter.class);
// wait for the window to be displayed
tester.waitForFrameShowing
("Convert Celsius to Fahrenheit")
}
To write the test, we create a method called testNegativeNumberInput(). This test method needs to get a reference to each of the GUI components that are being tested. One way Abbot gets a reference to a GUI component is by looking up a component of the appropriate class. This allows Abbot to continue to refer to different GUI components even if the layout changes.
ComponentReference ref =
new ComponentReference
("tempCelsius", JTextField.class);
Component tempCelsius =
getFinder().findComponent(ref);
The next step is to initialize the ComponentTester so that the user interaction event of typing in a negative number can be generated
tester = ComponentTester.
getTester(tempCelsius);
tester.actionKeyString(-45);
Once the sequence of user interactions is in place, we would need to verify if the result is correct by adding assertions. The reference to the label is obtained and then the value of the label is tested using assetEquals()
JLabel fahrenheitLabel =
(JLabel)getFinder().findComponent(ref);
assertEquals("-49 Fahrenheit",
"-49 Fahrenheit",
fahrenheitLabel.getText());
To run the test, the TestHelper class available in the test package in Abbot will be handy. The TestHelper class also provides automatic test suite generation functionality.
public static void main(String[] args){
TestHelper.runTests
(args,CelsiusConverterTest.class);
}
This method can be used in conjunction with JUnit test cases for the application logic to create a homogeneous test suite. The decision points in the application logic can be tested using normal JUnit tests. Test cases generated using Abbot will test for different user interaction scenarios.
Conclusion
Writing functional GUI tests can be a tedious task. The concepts from both of the testing scenarios mentioned can be combined to produce a comprehensive suite of tests. Abbot as a framework provides both scripting functionality and a Java API. The framework easily integrates with the JUnit test harness and therefore, during application development, the functional GUI tests can become a part of the test suite. All these features of Abbot make it an effective framework for rapidly creating a comprehensive test framework.
Resources
Published July 18, 2009 Reads 40,122
Copyright © 2009 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Satadip Dutta
Satadip Dutta is a software architect at Hewlett-Packard (http://devresource.hp.com) and has been programming in Java since 1997. His areas of interest include distributed software architecture, Web services, and user interface design. Satadip holds an MS in Computer Science from Virginia Tech.
![]() |
Ashwath 01/18/05 02:34:16 AM EST | |||
I tried to run the code that u haven for 'GUI already exista' scenario. But it doen't work.. give me some eg.s |
||||
![]() |
tlroche 08/22/03 10:05:14 PM EDT | |||
"Abbot for SWT" (project name=abbotforswt) is an Eclipse plugin https://w3.opensource.ibm.com/projects/abbotforswt/ (IIOSB residence is intended to be temporary. We are currently in IBM * how abbotforswt extends j.a.Robot and Abbot * abbotforswt vs blackbox tools (e.g. RobotJ/XDE Tester) * related Eclipse 3.0 plan items see the (currently rather crude) abbotforswt homepage To demonstrate abbotforswt's feasibility, we have taken scenario 2 Sound interesting? Try it out! However, first: <required type="legalese"> If you are an IBMer and have NOT already completed your "OSPG </required> You have 2 installation options. Instructions are for Eclipse/ 0 Install the release zip. Goto our release page read the "IMPORTANT NOTICE", then follow the instructions in the Note that you need not register for IIOSB to get the release, but we 1 Install from CVS. This is a good first step toward becoming an - Run your development workbench (devbench) with either Target - Create a new CVS repository location with host=cvs.opensource.ibm.com and check out HEAD/abbotforswt. - Browse to our release notes search or scroll to "run the demo" - Skip to step 4 The demo can then be run in each of 3 ways, all of which are * using Test Collector in a launched WebSphere Studio build * using pde.junit to launch an Eclipse or WS build * using Eclipse's JUnit to launch just the UI |
||||
![]() |
tlroche 08/22/03 09:55:08 PM EDT | |||
"Abbot for SWT" (project name=abbotforswt) is an Eclipse plugin which seeks to extend Abbot ... for SWT (but you guessed :-) It is currently available only from the IIOSB (a "walled garden" version of SourceForge inaccessible outside IBM) @ https://w3.opensource.ibm.com/projects/abbotforswt/ (IIOSB residence is intended to be temporary. We are currently in IBM Open Source Steering Committee pre-review, and therefore hope to contribute our extensions back to Abbot sometime this millenium :-) For more detail, including * how abbotforswt extends j.a.Robot and Abbot * abbotforswt vs blackbox tools (e.g. RobotJ/XDE Tester) * related Eclipse 3.0 plan items see the (currently rather crude) abbotforswt homepage http://w3.opensource.ibm.com/~abbotforswt/ To demonstrate abbotforswt's feasibility, we have taken scenario 2 from the JDJ article above, recoded its SUT (a dialog) in SWT, and designed and implemented an API targeting SWT equivalent to Abbot's existing API targeting AWT/Swing. For more details, see our release notes @ http://w3.opensource.ibm.com/project/shownotes.php?release_id=597 Sound interesting? Try it out! However, first: If you are an IBMer and have NOT already completed your "OSPG training," please read the Open Source Participation Guidelines http://ltc.linux.ibm.com/open_source/ospg.html before you check out any code. You have 2 installation options. Instructions are for Eclipse/ WebSphere Studio users: 0 Install the release zip. Goto our release page http://w3.opensource.ibm.com/project/showfiles.php?group_id=1023 read the "IMPORTANT NOTICE", then follow the instructions in the release notes http://w3.opensource.ibm.com/project/shownotes.php?release_id=597 Note that you need not register for IIOSB to get the release, but we hope you will, because you're a fine human being. (Apologies for speciesism to all the fine non-human programmers http://www.newtechusa.com/PPI/pressroom.asp#higher out there :-) 1 Install from CVS. This is a good first step toward becoming an abbotforswt contributor! - Run your development workbench (devbench) with either Target Platform pointing to a WSAD build (which is how I tested), or just import org.apache.xerces (should work, but not tested). - Create a new CVS repository location with host=cvs.opensource.ibm.com and check out HEAD/abbotforswt. - Browse to our release notes http://w3.opensource.ibm.com/project/shownotes.php?release_id=597 search or scroll to "run the demo" - Skip to step 4 The demo can then be run in each of 3 ways, all of which are documented in the release notes: * using Test Collector in a launched WebSphere Studio build * using pde.junit to launch an Eclipse or WS build * using Eclipse's JUnit to launch just the UI |
||||
![]() |
tlroche 08/22/03 09:51:39 PM EDT | |||
"Abbot for SWT" (project name=abbotforswt) is an Eclipse plugin which seeks to extend Abbot ... for SWT (but you guessed :-) It is currently available only from the IIOSB (a "walled garden" version of SourceForge inaccessible outside IBM) @ https://w3.opensource.ibm.com/projects/abbotforswt/ (IIOSB residence is intended to be temporary. We are currently in IBM Open Source Steering Committee pre-review, and therefore hope to contribute our extensions back to Abbot sometime this millenium :-) For more detail, including * how abbotforswt extends j.a.Robot and Abbot * abbotforswt vs blackbox tools (e.g. RobotJ/XDE Tester) * related Eclipse 3.0 plan items see the (currently rather crude) abbotforswt homepage http://w3.opensource.ibm.com/~abbotforswt/ To demonstrate abbotforswt's feasibility, we have taken scenario 2 from the JDJ article above, recoded its SUT (a dialog) in SWT, and designed and implemented an API targeting SWT equivalent to Abbot's existing API targeting AWT/Swing. For more details, see our release notes @ http://w3.opensource.ibm.com/project/shownotes.php?release_id=597 Sound interesting? Try it out! However, first: If you are an IBMer and have NOT already completed your "OSPG training," please read the Open Source Participation Guidelines http://ltc.linux.ibm.com/open_source/ospg.html before you check out any code. You have 2 installation options. Instructions are for Eclipse/ WebSphere Studio users: 0 Install the release zip. Goto our release page http://w3.opensource.ibm.com/project/showfiles.php?group_id=1023 read the "IMPORTANT NOTICE", then follow the instructions in the release notes http://w3.opensource.ibm.com/project/shownotes.php?release_id=597 Note that you need not register for IIOSB to get the release, but we hope you will, because you're a fine human being. (Apologies for speciesism to all the fine non-human programmers http://www.newtechusa.com/PPI/pressroom.asp#higher out there :-) 1 Install from CVS. This is a good first step toward becoming an abbotforswt contributor! - Run your development workbench (devbench) with either Target Platform pointing to a WSAD build (which is how I tested), or just import org.apache.xerces (should work, but not tested). - Create a new CVS repository location with host=cvs.opensource.ibm.com and check out HEAD/abbotforswt. - Browse to our release notes http://w3.opensource.ibm.com/project/shownotes.php?release_id=597 search or scroll to "run the demo" - Skip to step 4 The demo can then be run in each of 3 ways, all of which are documented in the release notes: * using Test Collector in a launched WebSphere Studio build * using pde.junit to launch an Eclipse or WS build * using Eclipse's JUnit to launch just the UI |
||||
![]() |
Jeff 04/29/03 08:26:00 PM EDT | |||
I believe this is a forum in which comments need to be made about the article and its vaildity. The above messages should be in English and any concerns/comments should be made available for the benefit for all in the community |
||||
![]() |
Bhojohori Manna 04/29/03 06:00:00 AM EDT | |||
Chee chee, Ei rokom gala gali dile hobe.Dada koto bhalo article likheche. |
||||
![]() |
Utgandu 04/29/03 05:54:00 AM EDT | |||
Dada,ei jinis poisa diye keu porbe bhebechen apni?USa te theke apnio sobar moto boka patha hoye gechen .Apni ei jinista kotha theke chotha korechen?Ar apni ki GUI Master ke chenen???jobab chai,jobab dao. |
||||
- Kindle 2 vs Nook
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- Confessions of a Ulitzer Addict
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- It's the Java vs. C++ Shootout Revisited!
- Cloud Computing Can Revitalize Your Career as Software Developer
- IBM Could "Reinvent" Java: Mills
- Oracle & Cloud Computing: Exclusive Q&A with SVP Richard Sarwal
- A Brief History of Cloud Computing
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- The i-Technology Right Stuff
- JavaServer Faces (JSF) vs Struts
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- What's New in Eclipse?
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- i-Technology Predictions for 2007: Where's It All Headed?








































