Introduction - Automation Automation testing which is also known as Test Automation, is when the testerwrites scripts and uses another software to test the software. This process involves automation of a manual process. Automation Testing is used to re-run the test scenarios that were performedmanually, quickly and repeatedly (regression). Apart from regression testing, Automation testing is also used to test theapplication from load, performance and stress point of view. It increases the test coverage; improve accuracy, saves time and money incomparison to manual testing.
What to Automate? It is not possible to automate everything in the Software; however the areasat which user can make transactions such as login form or registration formsetc, any area where large amount of users accessing. Furthermore all GUI items, connections with databases, field validations etccan be efficiently tested by automating too.
When to Automate? Test Automation should be uses by considering the following for the Software: Large and critical projects. Projects that require testing the same areas frequently. Requirements not changing frequently. Accessing the application for load and performance with many virtual users. Stable software with respect to manual testing. Availability of time.
How to Automate? Automation is done by using a supportive computer language like scriptinglanguage and an automated software application. There are a lot of tools available which can be use to write automationscripts. Software Testing Tools: HP Quick Test Professional, Selenium, JMeter,IBM Rational Functional Tester, SilkTest, TestComplete, Testing Anywhere,WinRunner, Load Runner, Visual Studio Test Professional, WATIR.
Introduction - JMeter Stefano Mazzocchi of the Apache Software Foundation was the original developer ofJMeter. He wrote it primarily to test the performance of Apache JServ (a projectthat has since been replaced by the Apache Tomcat project). Apache JMeter is a 100% pure Java desktop application designed to load testclient/server software (such as a web application ). It may be used to test performance both on static and dynamic resources such asstatic files, Java Servlets, CGI scripts, Java objects, databases , FTP servers , andmore. JMeter can be used to simulate a heavy load on a server, network or object to testits strength or to analyze overall performance under different load types. Additionally, JMeter can help you regression test your application by letting youcreate test scripts with assertions to validate that your application is returning theresults you expect. For maximum flexibility, JMeter lets you create these assertionsusing regular expressions. Note: JMeter is not a browser.
Getting started… The easiest way to begin using JMeter is to first download the latest productionrelease and install it. The release contains all of the files you need to build andrun most types of tests, e.g. Web (HTTP/HTTPS), FTP, JDBC, LDAP, Java, andJUnit. URL: http://jmeter.apache.org/download_jmeter.cgi Requirements: JMeter requires a fully compliant JVM/JRE 6 or higher. JMeter is a 100% Java application and should run correctly on any system that has acompliant Java implementation. Installation: To install a release build, simply unzip the zip/tar file into thedirectory where you want JMeter to be installed. Provided that you have aJRE/JDK correctly installed and the JAVA_HOME environment variable set, thereis nothing more for you to do.
Running – Jmeter…To run JMeter, run the jmeter.bat (for Windows) or jmeter (for Unix) file. These files arefound in the bin directory. After a short pause, the JMeter GUI should appear.
Building a Basic Web Test Plan… In this section, we will learn how to create a basic Test Plan to test a Web site. We will create five users that send requests to two pages on the JMeter Web site. Also, we will tell the users to run their tests twice. So, the total number of requests is (5 users) x (2 requests) x (repeat 2 times) = 20 HTTP requests. To construct the Test Plan, we will be using the following elements: Thread Group, HTTP Request,HTTP Request Defaults, and Graph Results (Note: There are many elements are available inJMeter – refer below URL: http://jmeter.apache.org/usermanual/index.html --> Section“Elements of a test plan”
Thread Group - Adding Users The Thread Group tells JMeter the number of users we want to simulate, how often the users shouldsend requests, and the how many requests they should send. Go ahead and add the ThreadGroup element by first selecting the Test Plan, clicking your rightmouse button to get the Add menu, and then select Add --> ThreadGroup. Next, increase the number of users (called threads) to 5. In the next field, the Ramp-Up Period, This property tells JMeter how long to delay betweenstarting each user. For example, if you enter a Ramp-Up Period of 5 seconds, JMeter will finishstarting all of your users by the end of the 5 seconds. So, if we have 5 users and a 5 second Ramp-Up Period, then the delay between starting users would be 1 second (5 users / 5 seconds = 1 userper second). If you set the value to 0, then JMeter will immediately start all of your users. Finally enter a value of 2 in the Loop Count field. This property tells JMeter how many times torepeat your test. If you enter a loop count value of 1, then JMeter will run your test only once. Tohave JMeter repeatedly run your Test Plan, select the Forever checkbox.
Note: The HTTP Request Defaults element does not tell JMeter to send an HTTP request.It simply defines the default values that the HTTP Request elements use.
Adding HTTP Requests In our Test Plan, we need to make two HTTP requests. The first one is for the JMeterhome page (http://jmeter.apache.org/), and the second one is for the Changes page(http://jmeter.apache.org/changes.html). JMeter sends requests in the order that they appear in the tree. Start by adding the first HTTP Request to the JMeter Users element (Add --> Sampler --> HTTP Request). Steps: Change the Name field to "Home Page". Set the Path field to "/". Remember that you do not have to set the Server Name fieldbecause you already specified this value in the HTTP Request Defaults element. Next, add the second HTTP Request and edit the following properties: Change the Name field to "Changes". Set the Path field to "/changes.html".
Listener- Adding a Graph Result The final element you need to add to your Test Plan is a Listener . This element is responsible for storing all of the results of your HTTP requests in a file andpresenting a visual model of the data. Select the JMeter Users element and add a Graph Results listener (Add --> Listener -->Graph Results). Next, we need to specify a directory and filename of the output file. You can either type itinto the filename field, or select the Browse button and browse to a directory and thenenter a filename.
Logging in to a web-site… Its not the case here, but some web-sites require you to login before permitting you toperform certain actions. In a web-browser, the login will be shown as a form for the username and password, and a button to submit the form. The button generates a POST request, passing the values of the form items as parameters. To do this in JMeter, add an HTTP Request, and set the method to POST. Youll need to know the names of the fields used by the form, and the target page. These can be found out by inspecting the code of the page.
Yes… we can – using one of the bestcomponents called “HTTP Proxy Server” The HTTP Proxy Server allows JMeter to watch and record your actions whileyou browse your web application with your normal browser. JMeter will create test sample objects and store them directly into your testplan as you go. To use the proxy server, add the HTTP Proxy Server element to theworkbench. Select the WorkBench element in the tree, and right-click on this element toget the Add menu (Add --> Non-Test Elements --> HTTP Proxy Server).
Step by step guide using HTTP ProxyServer… This tutorial attempts to explain the exact steps for JMeters proxy. For those new to JMeter, one easyway to create a test plan is to use the Proxy. What the proxy does is it records the requests sent to theserver.1. Go to JMETER_HOME/bin and start JMeter with jmeter.bat (on windows)2. Select “Test Plan” on the tree.3. Right click on the “Test Plan” and add a new thread group: Add > Threads (Users) > Thread Group
4. Select the Thread Group.5. Right click “Add -> Config Element -> HTTP Request Defaults”6. In new HTTP Request Defaults element: Server name – enter “jmeter.apache.org”7. Path – leave blank
8. Right click on the “Thread Group” and add a recording controller: Add > LogicController > Recording Controller
9. Next, select WorkBench10. Right click on WorkBench and add the Http proxy: Add -> Non-Test Elements -> HTTP Proxy Server
11. On HTTP Proxy Server, click the “Add” button in “URL Patterns to Include”. (This will create a blank entry).12. Enter “.*.html”13. Click 3 times, the “Add” button in “URL Patterns to Exclude”. (This will create 3 blank entries).14. Enter “.*.png” pattern, “.*.gif” pattern and “.*.ico” pattern
15. Right click on “HTTP Proxy Server” and add a listener: Add -> Listener -> View Results Tree
16. Return to HTTP Proxy Server, and click the “Start” button at the bottom.
Configure your brower to use the JMeter HTTP Proxy At this point, JMeters proxy is running. For this exercise, we will use Firefox to record some pages on JMeter.17. Start Firefox, but do not close JMeter.18. From the tool bar, click “Tools > Preferences”. This should bring up the options.19. Select the “Advanced” tab, and “Network” tab.20. Click “Settings” button near the bottom.
21. On the new popup, check “Manual proxy configuration”. The address and port fields should beenabled now.22. Address – enter “localhost” or the IP address of your system.23. Port – enter “8080”.24. Check the “Use this proxy server for all protocols”25. Click “ok” button26. Click “ok” button again. This should return you to the browser.
Record your navigation27. With your brower, in the “Address” bar at the top, enter“http://jmeter.apache.org/index.html” and hit the “enter” key.28. Click on a few links on JMeters pages.29. Close your browser and bring up the JMeter window.Expand the thread group and there should be several samplers. At this point,the test plan can be saved as is.
30. Select “Thread Group”.31. Right click “Add -> Listener -> Summary Report” to add an summary listener.32. The summary listener will show some basic statistics.
33. Select “Thread Group”.34. Number of Threads – enter “5”.35. Ramp up Period – do not change.36. Loop Count – enter 100
Start the test (with test plan)…At this point, we are ready to run our test plan and see what happens. Save the test plan.When youre ready to run the test, theres two ways:1. Run -> Start2. Ctrl–RBefore you start the test, select “Summary Report”. As the test runs, the statistics will changeuntil the test is done. At the end of the test, the summary report should look like this.While the test is running, in the upper right-hand corner, there should be a green square.When the test is done, the box should be grey.