Blogs

JMeter Basics

JMeter is a pure Java-based open source software that was first developed by Stefano Mazzocchi of the Apache Software Foundation. It has been designed to load test functional behavior and measure the performance of web applications. JMeter has a graphical interface that uses the Swing graphical API. Therefore, it can run on any environment that accepts a Java virtual machine, for examples Windows, Linux, Mac, etc.

  • From Sandali
  • December 14, 2020
tools

What is JMeter

For an instance, assume that there are some functionalities in an application and a person wants to test how the functionalities will behave when a large number of users are going to work on the application simultaneously. In that case, JMeter can be used to analyze and measure the performance of the application. JMeter is mainly used for performance testing which is a software testing type uses to ensure that the software applications perform well under their expected workload.

Why JMeter

The main reason for using JMeter is that it is a powerful tool with so many capabilities. Basically, JMeter is used for performance testing but it also can be used for non-functional testing such as stress testing, distributed testing, web service testing, volume testing, spike testing, endurance testing, and so on.

For example, assume that a person wants to do performance testing of www.google.com for 100 users. It is not feasible to arrange 100 people with 100 PCs and internet access simultaneously. Therefore, there should be a software tool like JMeter that will simulate the real-user behaviors and performance/load test of the software applications. That is the basic idea of JMeter.

JMeter Features

Following are some of the features of JMeter.

  • Ability to load and performance test many different applications/server/protocols such as Web – HTTP, HTTPS (Java, NodeJS, PHP, ASP.Net), SOAP/ REST web services, FTP

  • Being an open source software, it is freely available.
  • It has a simple GUI so that it is easy to work with JMeter.
  • It is a platform-independent tool. On Linux/Unix, JMeter can be invoked by clicking on JMeter shell script. On Windows, it can be invoked by starting the jmeter.bat file.
  • JMeter stores the test plans in XML format. This means it allows to generate a test plan using a text editor. (A test plan describes a series of steps JMeter will execute when run. A complete test plan will consist of one or more Thread Groups, logic controllers, sample generating controllers, listeners, timers, assertions, and configuration elements.)
  • It is highly extensible which means that it allows the addition of new capabilities and functionality

How does JMeter work

Basically, JMeter acts like a group of users sending requests to a target server. It collects response from the target server and other statistics which show the performance of the application or server via graphs or tables.

According to the above figure, there is a thread group which is a collection of single threads and each thread represents one user. JMeter allows the user to determine the number of threads for the group. For example, if a user needs 100 users then he/she can set the number of threads to 100. JMeter allows sending different types of requests to a server. The actual requests, that are being sent to the web server from JMeter is called Samplers. Here samplers tell which type of request (Whether it is http/ https/ ftp) the user makes. Imagine that a user wants to perform a test on a web server. So, there is this http request sampler that allows the user to send an http or https request to a web server.

JMeter Advantages

  • Open source license: JMeter is totally free and it allows the developer to use the source code for the development
  • User-Friendly GUI: JMeter is easy to use
  • Platform independent: JMeter can run on multiple platforms
  • Visualize Test Result: The JMeter test results can be displayed in a different format such as chart, table, tree and log file
  • Multiple testing strategies: JMeter supports many testing strategies such as Load Testing, Distributed Testing, and Functional Testing.
  • Simulation: JMeter can simulate multiple users with concurrent threads and create a heavy load against web application under test
  • Record & Playback - Record the user activity on the browser and simulate them in a web application using JMeter

JMeter Disadvantages

  • Has a high learning curve thus it requires skilled testers.
  • Complex applications that use dynamic content like CSRF tokens, or use JS to alter requests can be difficult to test using JMeter. (CSRF (Cross-site request forgery) tokens are, how they protect against CSRF attacks,)
  • Memory consumption is high which causes it gives out errors for many users

QA Testing Tools

Software Testing tools are the tools that are used for the testing of software. These tools are often used to assure firmness, thoroughness, and performance in testing software products. These tools are used to fulfill all the requirements of planned testing activities.

  • From Vishathri
  • October 30, 2020
tools

What is QA Testing

QA stands for Quality Assurance. At a high level, QA Testing exists to confirm that the product you are making is, the product that the customer wants and released with no bugs.

Back in the day, software developers would build the software, hand it over to QA testers, and testers would manually test software and send back a list of bugs to be fixed.

The new wave of QA is more efficient, which means that QA is involved in every step of the agile development process. QA testers are sitting on design meetings, are on calls with clients, are in all the standups, and are looking at code as soon as developers are writing it, instead of waiting for the whole product to be done.

A QA tester is specialized in having the customer mindset championing the customers and asking questions to make sure that everybody is on the same page and nothing is missed. In the long haul, QA saves time and money.

Why we use testing tools

All software requires extensive testing before being rolled out to the public. Quality control engineers use both Open Source and commercial tools for testing based on the requirements for the type of software that is being built.

Categories of QA tools

QA testing tools can generally be categorized into three main categories.

  • Test management tools
    • These tools help quality assurance engineers look at the requirements and write appropriate test cases for them. The tools help with test case creation, planning, and execution. Once executed, the test management tools create and track bugs against requirements.

    • For that, a couple of tools that can be used for test management:

      • Mantis Bug Tracker – This is an open-source test management tool and is simple to use, allows teammates to collaborate.
      • TestCollab or IBM Rational Quality Manager– This tool helps manage and plan test cases along with producing in-depth reports of the test execution statuses. This tool integrates with various other bug management tools as well.

  • Functional testing tools

  • These tools enable the quality assurance engineer to test the individual features or pieces of software and then report errors to the development team. These tools can enable automated testing or manual testing. Selenium and Cucumber are popular functional testing tools that can be used frequently


    Selenium – when it comes to selenium, there are two types.

    • Selenium WebDriver
    • Selenium IDE
    • Selenium WebDriver enables automation testing to create functional tests and regression automation test suites.
    • Selenium IDE QA can record a series of steps to execute on a browser multiple times and helps in exploratory testing.

    Cucumber – enables automated testing along with behavior-driven development. Functional tests are written in plain text and can be automated with scripts in Ruby, Java, .Net, PHP, and many more languages.


  • API Testing Tools

  • These tools help test the service layer or the APIs. Input parameters can be provided by the QA engineer to ensure the output parameters run as expected.


    Here are some popular apps for API testing

    • Postman – This is a lightweight API testing tool that can be used both by API developers, API integrators, and a QA team looking for quick answers during the testing phase.
    • Apiary – With the use of a markdown language, Apiary guides both testing and development of APIs. This tool includes testing scripts, validations, and code samples for the API’s as well.

  • Unit Testing Tools

  • Unit testing tools are meant to test individual pieces of the code and are generally used by developers to test functionality and code quality.

    • JUnit, NUnit, PHPUnit – These are unit testing languages for Java, .Net, and PHP.
    • SonarQube, Code Coverage – are tools that ensure quality management on the code itself, which in turn affects the quality of the product and bugs in the QA cycle.
    • Our Office
  • Multi-Browser Testing Tools

    • These tools enable cross-browsers testing across multiple browser and OS versions.

    • Sauce Labs – This service, along with Selenium, runs automated scripts in multiple browsers including both desktop and mobile browsers. The service captures screenshots and creates reports that help identify browser-specific bugs.
    • Browser Stack – Similar to Sauce Labs, this service enables cross-browser testing across both desktop and mobile browsers.

  • Multi-Device Testing Tools

  • Mobile apps span across multiple device OS versions and multiple screen resolutions, making the QA cycle difficult. The purchasing range of real devices to test on becomes impractical and time-consuming as well. There are several tools to choose from that can eliminate this issue

    • Device Emulators – While emulators are not ideal for all testing, they are free and easily available.
    • Amazon Device Farm – This service enables a user to upload an app to Android or Fire OS and test it on real devices to get testing results.
    • DeviceAnywhere – This service lets you test on real devices for both Android and iOS. This has a free and paid version.

  • Performance Testing Tools
  • Every product has a tipping point when the performance of the app starts going down. These performance testing tools let you determine how scalable and reliable your application is. A few tools that enable performance testing are

    • Soasta Cloud Test – These tests virtual users across various locations to test quickly and continuously at any scale. The test provides real-time insights on the performance of your app.
    • Load Runner – This service accesses the performance of both browser-based applications and native mobile applications. It runs tests from multiple locations as well as running testing in the cloud.

Page Object Model (POM), Maven, testNG in selenium

Maintaining many lines of code in one set of threads is a difficult task and increases its complexity. In your project structure and selenium script to be effective, you must use different pages for different concepts. To set up a code distribution between different modules. In this article on the Selenium page format, you will be given an example of some basic concepts of the page format and the factory on the pages.

  • From Monika
  • September 25, 2020
Our Office

Why POM?

POM has nowadays become a popular test automation design pattern around the testing industry. POM facilitates as to concentrate on testing the AUT rather than fixing the automation suite (the changed objects) to perform the test. In POM the Object information is managed outside the test script, thus making it easy to understand the test script.

Advantages of POM

  • It makes ease in maintaining the code (flow in the UI separated from verification)
  • Makes the code readable (Methods get more realistic names)
  • Makes the code reusable (object repository is independent of test cases)
  • The code becomes less and optimized

Implementation of POM

Let us consider a simple test scenario where we have an app with a login page, an account page, and, say, the home page.

The scenario be like

  • We go to the app URL
  • Validate the app page is correct (home page)
  • We go to the login page and fill the form with a valid id and password
  • We validate if the account page opens

Selenium

First, Selenium is an open source tool that you can use to automate tests that you need to run on existing web browsers. (Simply put, test your web application with a web browser such as Google Chrome, Mozilla Firefox, Opera browser, Internet Explorer, or MS Edge.)

Before exploring your imagination, here is one very important thing about Selenium. This means that you can only use Selenium for test web applications, not software (desktop applications). You can consider this one of the disadvantages of Selenium, which I will explain later.


The good thing is that you can automate software and mobile app testing with other available tools like RFT from IBM, QPT from HP, Appium, etc.


We discussed above that Selenium is an open source, which means you do not have to pay licensing fees to use this tool, and this is one of the main and top reasons why this trend in test automation is so popular. Other advantages and benefits of using Selenium are as follows;


  • Quality Analyst can write test scripts using programming platforms such as C #, PHP, .NET, Java, Python, Ruby, and Perl.
  • Testing can be carried out not only on one operating system, but also on Windows, Mac or Linux.
  • You can use other browsers like Mozilla Firefox, Google Chrome, Internet Explorer, Opera and Safari to get this job done.
  • Tools like TestNG and Junit can integrate with Selenium to generate reports and manage test cases.
  • Maven, Jenkins and Docker can also be integrated with Selenium for continuous testing.
  • By now, you should be thinking about whether selenium is so perfect that this approach has no limitations, drawbacks, or drawbacks. So here is the answer to your confusion.

Here are the disadvantages of Selenium

Most importantly in this category, you can only test web applications using Selenium, not desktop applications or other software.

Currently, there is no dedicated product support for Selenium users. You need to rely on the online user community to share issues and find solutions to issues.

Selenium does not have native reporting capabilities, but you can integrate Selenium with TestNG or JUnit to solve this problem if you need to.


Maven

  • What is Maven?

Maven is a build directory test of source directory dependencies. The source directory is a powerful project/build management tool based on the POM (Project Object Model) concept that contains Maven projects such as plugins and configuration information.


  • Reasons to choose Maven and Selenium

The integration of Maven and Selenium has the following advantages: Provides support for managing the life cycle of Apache Maven test projects.


    • Maven is used to defines dependency builds and test management for project structures.
    • You can use pom.xml (Maven) to set the dependencies needed to build your tests and run your code.
    • Maven will automatically download the required files from the store while building the project.

testNG

Most programmers are busy writing code and forget the importance of testing the implementation on the fly. When you start writing tests, you need to choose the framework that works best for your job. Otherwise, the situation will get worse.


TestNG is a testing framework that was triggered by JUnit and NUnit, but some of the more powerful and easy-to-use new features are being introduced, such as:


  • Annotations.
    • @BeforeSuite:

      The annotated method will be run before all tests in this suite have run.
    • @AfterSuite:

      The annotated method will be run after all tests in this suite have run.
    • @BeforeTest:

      The annotated method will be run before any test method belonging to the classes inside the tag is run..
    • @AfterTest:

      The annotated method will be run after all the test methods belonging to the classes inside the tag have run.
    • @BeforeGroups:

      The list of groups that this configuration method will run before. This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked.
    • @AfterGroups:

      The list of groups that this configuration method will run after. This method is guaranteed to run shortly after the last test method that belongs to any of these groups is invoked.
    • @BeforeClass:

      The annotated method will be run before the first test method in the current class is invoked.
    • @AfterClass:

      The annotated method will be run after all the test methods in the current class have been run.
    • @BeforeMethod:

      The annotated method will be run before each test method.
    • @AfterMethod

      The annotated method will be run after each test method.

  • Run your tests in an arbitrary large thread pool where you can use different policies (one thread per test class for every method in its own thread, etc.).
  • Your code tests multithreaded safety.
  • Flexible test configuration.
  • Data driven testing support (using @DataProvider).
  • Support parameters.
  • Powerful execution model (except TestSuite).
  • It is supported by various tools and plugins (Eclipse, IDEA, Maven, etc.).
  • BeanShell integration improves more flexibility.
  • Basic JDK functions for runtime and logging (no dependencies).
  • Application server test dependent method.
  • TestNG is designed to cover all test categories including device function end-to-end integration.

Sample project

  • Create a Maven Project in Eclipse IDE.

    Open Eclipse and right click on Package Explorer. Select New >> Maven project. And click the Next button.


    Our Office
  • Tick the <Create a Simple Project (skip archetype selection)> checkbox and click Next.


    Our Office
  • Fill the group id, artifact id, and name. And click the Finish button to create the project.


    Our Office
  • The project structure would look something like the one shown in the below image.


    Our Office
  • Also, you must make sure that the Installed JRE setting is correctly pointing to a JDK path on your system. You can change it from the Preferences window.


    Our Office
  • Every Maven project uses a POM file to add the required dependencies. So we will also be adding some libs required for our WebDriver Maven project. Namely, these are the Selenium and TestNG JAR files. Please check from the below screenshot.

    Note: Make sure you provide the correct version for each dependency you add in the POM.


    Our Office

    You can verify testNG installed or not, navigating Eclipse marketplace.

Follow the below file structure. And you can simply understand code structure.


Our Office
  • Base Class


    Our Office
  • Business Class


    Our Office
  • Page elements class


    Our Office
  • Test Class


    Our Office

If necessary, you can be enhanced page object model folder structure as your wish.


React JS

This post is about a tech talk I did regarding React JS at Cypad Pvt Ltd. It introduces the basic concepts of React and the features it provides. It also gives an idea of which type of scenarios is it good to use React over an alternative.

  • From Sameer
  • June 21, 2020
Our Office

Overview

  • The first thing to know about React is that it is a library and not a framework. This is because it does only one thing really well, which is UI Development.
  • It was created by Facebook and was released to the public in 2013. Even before that, they had been using this for internal development purposes for some time so it was very stable even just after its initial release.
  • The developers of React have created a syntax extension to JS called JSX which developers are recommended to use.
  • It's open-source so it is free to use and you can contribute to it if you want.
  • It has become extremely popular during the recent years and it is more widely used than angular. It is used by companies like Uber, Airbnb, and Twitter. Since it's very widely used, if you get a problem there are a lot of other developers out there who can help you on sites like Stack Overflow.

Main Points to Note

It is component-based, so the whole application can be divided into reusable components.
In components the HTML and JS are not separated into two, they are kept in the same file. So developers are discouraged to make components very large.
A very important difference between React and other frameworks and libraries is that React operates on something called a Virtual DOM which makes updating the UI very fast. This is done automatically so the developers don't have to worry about it.
And when it comes to data binding - React only natively supports one-way data binding. This means you can show JS variables in the UI, but getting data from the UI by for example from a form is not natively supported. You have to manually write code to get the data from the HTML element (a simple is sufficient).
React by default renders on the client-side but server-side rendering can be set up easily if needed.

Components

There are 2 types of components

  • Functional components
  • Class components

A point to note is that functional components are stateless, so they do not have separate attributes (data fields) of their own. And they are used to doing simple things like rendering a single table row or maybe some text. Components have 2 data stores called

  • State
  • Props

Functional components only have props while class components have both. The state is used to store the components data while props are used to pass data from component to component.

JSX

JSX is a syntax extension to JS. The default method of instantiating a React component is like this.


React.createElement(component, props, [

React.createElement(child1, props, [

React.createElement(child3),

React.createElement(child4),

]),

React.createElement(child2)

])


And JSX makes it more like HTML which is easier to understand.

<component props="...">

<child1 >

<child3 />

</child1>

<child2 />

<component>


The difference in simplicity and ease of understanding is greater when there is a complex hierarchy of components.

State

The difference in simplicity and ease of understanding is greater when there is a complex hierarchy of components.

State

The state of a component is a data store that contains data fields that are specific to the component. The data only exists within the component.

Passing Data

Our Office

When it comes to passing data there are basically 3 scenarios

  1. Passing data downwards (Parent to Child)
  2. Passing data upwards (Child to Parent)
  3. Passing data across (Child to Child)

Scenario 1 - Passing data down to child components is done using props. So when component A sends a variable down to component B, it can be accessed through its props.

Scenario 2 - Passing data upwards becomes slightly complicated. It is done through callbacks. For example, data needs to be sent from B to A. You write a function in component A which is a setter, you write a setter function in A. Then you pass the setter function to component B as a prop. So when you call the setter function in component B you set the data to the variable in component A. This example was just one level, if you want to send data upwards for more than one level it becomes a bit confusing.

Scenario 3 - Passing data across components. This is one of the things that React is not very good at doing. There are 3 methods of doing this.

  1. The first is a combination of Props and callbacks which is not recommended because it can make the app very complicated for no proper reason.
  2. React created a solution to this called React Context API which makes a bit easier to do. But still it is not that easy to do.
  3. The third method is using a 3rd party state container. This is the go-to method for passing data across components. Redux is very commonly used with React JS.

Virtual DOM

React uses something called the Virtual DOM to send updates to the UI. When you make a change to the UI the change is performed on the virtual DOM, then the rendering engine finds the relevant elements and updates only them. This makes React really fast at updating the UI.

Instead of the whole DOM being updated when something minor is changed, only the specific element which is changed is updated in the real DOM.

Portability to Mobile

React apps are portable to mobile using React Native. Not all of the code but most of the same code can be run in mobile phones. This is something to keep in mind when choosing the right technology for the development of an app.

Bundle Size Comparison

Below shown is a comparison of the NPM packages of React and Angular. Information is taken from Bundlephobia

Our Office

Pros

Major

  • Lightweight - Small bundle sizes (Faster initial load, especially on mobile devices)
  • Flexible - Gives the developers a lot of freedom
  • Portable to Mobile - iOS and Android

Minor (but significant)

  • Easy to learn
  • One-way binding - Which is more stable than two-way binding
  • Virtual DOM - Provides high performance. Considered a minor advantage because alternatives like Angular have similar technologies (Incremental DOM) to achieve the same performance

Cons

  • Very Limited capabilities
  • Heavily reliant on third-party libraries
    • Breaking changes
    • Unmaintained
    • Security flaws

Situations in which you can use React

  • The flexibility of React makes it a good JS library for beginners to learn but is also scalable enough for large companies who need to build large complicated applications.
  • If an app is going to be ported into mobile operating systems in the future using React JS might be the solution because it will save you from the trouble of maintaining two codebases for each of the OSes.
  • If an application's back-end API handles alls the processing it might be a good idea to use React because then the front-end doesn't need to have a lot of logic and be kept as small as possible.

If these situations apply to a project you are working on or if the pros and cons are in you favor React JS may be what you should use.

I hope you learned something useful about React or at least refresh your existing knowledge.
Thanks for the read.


Top