Testing: An open source load testing tool

There is an easy way to load test simultaneous users in the application. The name of open source tool is called as Locust

Here is sample locust implementation of locust on my github repository (its pure python, no xml etc)

https://github.com/premaseem/load_testing_with_locust

Framework link  https://locust.io/

 

Getting Started

Once installed, the first thing you need to do is write your test case, which is just a few lines of simple Python. Mine looks like this.

from locust import HttpLocust, TaskSet, task

json = """
[{
  timestamp: 1339594030236,
  type: test_event,
  fields: [
    { foo: 'FOO' },
    { bar: 'BAR' },
  ],
  version: 1
}]
"""

class MyTaskSet(TaskSet):
    @task
    def send(l):
        l.client.post("/", json)                                                                                                              

class MyLocust(HttpLocust):
    task_set = MyTaskSet
    min_wait = 5000
    max_wait = 15000

I only have one URL to test, so it’s pretty simple. I make a POST request to this URL with some JSON.

To start Locust, simply run the locust tool, passing in the host you want to test.

locust -H http://localhost:37010

It’s not doing anything at the moment. To start the load testing, you need to open up the web interface at http://127.0.0.1:8089 (if your’re running Locust locally) and choose the amount of users to simulate, and their hatch rate (i.e. how fast the users will spawn).

testNG : How to ignore or disable a test in testNG

Some times a failing test causes the build to fail. In that cases before the test is fixed a quick remedy is to disable the test to get the build passed. That can be done easily through annotation.

@Test(enabled=false)

The TestNG engine will just bypass this method.

import org.testng.annotations.*;

public class TestNGTest3 {

	@Test(enabled=false)
	public void divisionWithException() {  
	  System.out.println("Method is not ready yet");
	}  

}

In above example, TestNG will not test the divisionWithException() method.