Posted by
sapan
on
- Get link
- Other Apps
chalba -newFile
It will generate the file name Task1.java
in the current directory.package chalba;
import skd.chalba.common.*;
import skd.chalba.requests.*;
import skd.chalba.runner.*;
import skd.chalba.interfaces.*;
/**
* This is the template File for writing the load script
* Please follow the structure as described in this file
*
* @author sapan.dang
*/
@ThreadCount(1)
@ThreadSpawnDelay(100)
public class Task1 extends Task {
// this constructor is required
public Task1(TaskParams taskParams) {
}
//This method is executed after constructor
//script must implement this method
@Override
public void run() {
super.run();
//executable method
//it is good practice to write your code in other method
mainLoop();
_testCompleted(); //call when the test is complete
}
//Main Loop write your logic here
public void mainLoop() {
//Write your code in the try-catch block
//to avoid any unexpected closure of the script
try {
//create GET request
System.out.println("send get request");
ResponseData googleResponse = requests.get("https://www.google.com/");
System.out.println("response code " + googleResponse.code);
//create async request
requests.get("https://www.google.com/", new AsyncResponseCallback() {
@Override
public void onResponse(ResponseData arg0) {
System.out.println(" "+arg0.body);
}
});
} catch (Exception e) {
LOG(e);
}
}
}
The script is java class file. So you can code using any IDE just add chalba.jar found inside the lib directory of chalba
in the classpath of the IDE.as from the document
currently chalab support only GET and POST methods.
chalba -f Task1.java
It will exeute the Task1.java. chalba writes logs in chalba.log and reponses are logged in response.ctl this is the csv file
.chalaba documentation https://buglens.com/guide/guide/
Comments
Post a comment