Thursday 3 December 2015

Configuring JMeter

As we already discussed in previous and first post of JMeter is that JMeter is 100% pure Java application, hence it is required to have installed JVM on your system.

Following are the minimum requirement before you try to run JMeter :

Java Environment
  • Minimum Java Version 1.6 or higher is best. Follow the instructions on Oracle's official website to see how to set the JAVA_HOME environmental variable.
Operating System
  • Any operating system which has Java compliant implementation should be able to run JMeter without any problem.
Running JMeter
  • Once the JVM is set and running, download the JMeter release or nightly build and unzip in local drive.
  • If you are running JMeter on Windows. Go to JMeter's unzipped directory and navigate to bin directory and run jmeter.bat file.
  • If you are running JMeter on Linux/Unix system. Go to JMeter's unzipped directory and navigate to bin directory and run jmeter.sh file using terminal.
  • If you are running JMeter on Mac. Go to JMeter's unzipped directory and navigate to bin directory and run jmeter.sh file using terminal.
 JMeter UI
This is the view of JMeter you will see after launching it:
 












Stay tuned to see more updates on JMeter.

Facebook Page : https://www.facebook.com/crazzzygig 

References : http://jmeter.apache.org/

Saturday 28 November 2015

Introduction To JMeter

JMeter is an open source software by Apache Software Foundation, a 100% pure Java application designed to measure performance. Initially it was designed to test Web Application but later expanded to test other test functions.

The protocols supported by JMeter are:
  • Web – HTTP, HTTPS.
  • SOAP / REST
  • FTP
  • Database via JDBC
  • LDAP
  • Message-oriented middleware (MOM) via JMS
  • Mail – SMTP(S), POP3(S) and IMAP(S)
  • MongoDB (NoSQL)
  • Native Command or Shell Scripts
  • TCP

Following are the features of JMeter:
  • As it is open source software, it is available for free.
  • JMeter is a platform-independent software. On Windows it can be invoked by starting the jmeter.bat file and on Linux it cab be invoked by clicking the JMeter shell script.
  • JMeter stores its test plans in XML format.
  • JMeter is a multi-threading framework allows concurrent sampling by many threads and simultaneous sampling of different functions by separate threads group(Users).
  • JMeter can also be used to test automated and functional testing of the application.

Following are the terms you will encounter frequently while using JMeter:
  • Test Plan – A test plan describes a series of steps JMeter will execute when run. A test plan can consist of one or more Thread Groups, Controllers, Samplers, Listeners, Timers, Assertions and Configuration elements.
  • Thread Group – Thread Groups is a collection of groups.Basically each thread represents one user running against the Application Under Test(AUT). It is the starting point under the test plan.
  • Samplers – Samplers are the way to send all types of requests to server supported by JMeter.
  • Controllers – Controllers allows you to control when to send a user request to a server. There are various type of controllers such as logic controller etc., we will discuss those in detail in later posts.
  • Listeners – Listeners are nothing but way to show the results of samplers in form of tables, graphs, trees or in simple text format.
  • Timers – While sending requests JMeter thread sends request without any pause between each sampler. Timers allows you to define a period to wait between each request.
  • Assertions – As it is self defined word provides the capability to include some validation on the response of the request sent. By using different assertions we can assure that sent request is returning correct or expected data.
  • Configuration Elements – There are various configuration elements in JMeter, it works very closely with samplers and can only be accessed inside the three branch where it is placed. It allows to create defaults and variables to be used by samplers.
Stay tuned to see more updates on JMeter.



References: http://jmeter.apache.org/

Sunday 16 August 2015

TestNG-XSLT Report Using Maven


An effective communication is the key to success. The knowledge and skills you acquire are of no use to others if it is not conveyed well. You will have to be able to gather information, organize it, and present it in a logical and concise form to convey the exact meaning you intend.

In the same way Reporting is the most important and critical part of any automated test execution, as it helps users and stakeholders to understand the exact result of the execution, reasons for the failures and also helps to determine the next steps.

As we have already seen TestNG default report in previous post (TestNg Link), so in this post we will focus on how to make reporting more presentable using XSLT. XSLT or Extensible Stylesheet Language Transformations is a language for transforming XML documents into other XML or other formats. It is intended to perform complex styling operations, like generation of tables of contents and indexes.

In this post we will see how to implement XSLT report using TestNG and Maven. Following are the tools being used for this post:

Maven: A Build Management Tool

TestNG: A Test Automation Framework

Selenium WebDriver: A Web Test Automation Tool

Setup all these tools in choice of your IDE; in this post we are using Eclipse IDE. Now, create a maven project and open the auto-generated pom.xml. Edit your pom.xml as written below:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
         http://maven.apache.org/xsd/maven-4.0.0.xsd">
       
       <modelVersion>4.0.0</modelVersion>

       <groupId>com.blogger</groupId>
       <artifactId>xsltreport</artifactId>
       <version>0.0.1-SNAPSHOT</version>
       <packaging>jar</packaging>

       <name>xsltreport</name>
       <url>http://maven.apache.org</url>

       <properties>
              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       </properties>

       <dependencies>
              <dependency>
                     <groupId>org.seleniumhq.selenium</groupId>
                     <artifactId>selenium-java</artifactId>
                     <version>2.45.0</version>
              </dependency>


              <dependency>
                     <groupId>org.testng</groupId>
                     <artifactId>testng</artifactId>
                     <version>6.8.21</version>
              </dependency>

       </dependencies>

       <build>
              <sourceDirectory>src/test/java</sourceDirectory>
              <plugins>
                     <plugin>
                           <groupId>org.apache.maven.plugins</groupId>
                           <artifactId>maven-surefire-plugin</artifactId>
                           <version>2.14.1</version>
                           <configuration>
                                  <testFailureIgnore>true</testFailureIgnore>
                                  <skipTests>false</skipTests>
                                  <suiteXmlFiles>
                                         <suiteXmlFile>testng.xml</suiteXmlFile>
                                  </suiteXmlFiles>
                           </configuration>
                     </plugin>
                     <plugin>
                           <artifactId>maven-compiler-plugin</artifactId>
                           <configuration>
                                  <encoding>iso-8859-1</encoding>
                                  <source>1.6</source>
                                  <target>1.6</target>
                           </configuration>
                     </plugin>
              </plugins>
       </build>

       <reporting>
              <plugins>
                     <!-- TestNG-xslt related configuration. -->
                     <plugin>
                           <groupId>org.reportyng</groupId>
                           <artifactId>reporty-ng</artifactId>
                           <version>1.2</version>
                           <configuration>
                                  <!-- Output directory for the testng xslt report -->
                                  <outputDir>/target/testng-xslt-report</outputDir>
                                  <sortTestCaseLinks>true</sortTestCaseLinks>
                                                        <testDetailsFilter>FAIL,SKIP,PASS,CONF,BY_CLASS</testDetailsFilter>
                                  <showRuntimeTotals>true</showRuntimeTotals>
                           </configuration>
                     </plugin>
              </plugins>
       </reporting>

       <pluginRepositories>
              <pluginRepository>
                     <id>reporty-ng</id>
                     <url>https://github.com/cosminaru/reporty-      ng/raw/master/dist/maven</url>
              </pluginRepository>
       </pluginRepositories>

</project>

In the above pom.xml we have added following components:

Selenium and TestNG Maven dependencies

build block containing Surefire plugin and maven-compiler plugin.

reporting block containing configuration of Testng-XSLT report.

pluginrepository block containing location of the reporty-ng.

Now we are done with the pom.xml configurations and it’s time to move further. Following the structure of the project created for this post:



As you can see we have two test classes along with three more xml files except pom.xml. In which testng.xml is being used to define the suite files and suiteA.xml and suiteB.xml are separate files for each test classes. We have separated these two test classes in different xml files just to show how the report will look like when we have multiple test suites.

suiteA.xml








suiteB.xml











testng.xml













Now we are ready to execute to the test and generate TestNG-XSLT report. To execute the test we will use maven command.

Navigate to workspace directory where pom.xml is present and run the following command:

mvn clean test -fae site org.reportyng:reporty-ng:1.2:reporting

After successful completion of the execution you will see BUILD SUCCESS information on command prompt.










Now go through the reporting block of pom.xml and see the mentioned path for XSLT report. In our case it is: <outputDir>/target/testng-xslt-report</outputDir>


Navigate to the mentioned directory and you will see the index.html file.

Index.html


















In this view you can see complete summary of passed, failed and skipped tests. The pie chart shows the percentage of all passed, failed and skipped tests. With this view a user can easily understand the status of the build and can decide the further steps to take.

For detailed status of the different suites, click on each of the link from the sidebar.

In sanity suite all the test cases have been passed.












In Regression suite one test failed, one passed and one skipped.











Please like and comment if you liked the post.  Stay tuned to see more posts.





Wednesday 28 January 2015

TestNG

TestNG is an open-source automated testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use. Functionality such as use of annotations for dependency testing, test in groups, email-able reporting, multi-threaded testing, data-driven testing, flexible plug-in API etc..

TestNG is designed to cover all categories of tests such as unit, functional, end-to-end, integration, etc..

In this post we will see a simple example how to use TestNG to execute test cases. In this post we are using following tools:
  1. Eclipse IDE
  2. Maven
First, Add the TestNG plugin in Eclipse either using the eclipse market place or Install new software option, Now Create a Maven project in Eclipse and add following dependency in pom.xml and build the project:

<dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.7</version>
        <scope>test</scope>
</dependency>

Code:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class LaunchBrowser {

 WebDriver driver;

 @BeforeClass
 public void setup(){
  System.setProperty("webdriver.chrome.driver",
    "E:/WorkSpace/Drivers/chromedriver.exe");
  driver = new ChromeDriver();
 }


 @Test
 public void LaunchPage(){
  try{
   driver.get("http://www.google.com/");
  }catch(Exception e){
   e.printStackTrace();
  }
 }
 
 @AfterClass
 public void tearDown(){
  driver.quit();
 }

}

In this example we are using TestNG annotations to drive the test.

@BeforeClass: To execute the method before the first test method of the class is invoked.
@Test: Mark the method as part of the test.
@AfterClass: To execute the method after all the test method of the current class have been run.

Now to run the test do right-click on the workspace and select Run as >> TestNG Test option. After completion of the execution you can see the report generated at following location:

Project root\test-output\emailable-report.html











Stay tuned to see next post on more about TestNG.

Facebook Page: https://www.facebook.com/crazzzygig

Please like and comment on our post and page if you like the blog.

References: http://testng.org/