Skip to content
Imad laghrissi edited this page May 13, 2020 · 6 revisions

Configure JMeter in windows

Add User Variables add **JMETER_HOME ** followed by D:\Jmeter (Where Jmeter is installed) Next select **Path ** in User variables and add D:\Jmeter\bin(Where Jmeter bin path is) Save and restart cmd

Run JMeter test with cmd

jmeter -n –t test.jmx -l testresults.jtl

Options

-n: It specifies JMeter is to run in non-gui mode
-t: Name of JMX file that contains the Test Plan
-l: Name of JTL(JMeter text logs) file to log results
-j: Name of JMeter run log file
-Jnb_thread: if you have a variable named ${__P(nb_thread, 1)} (always -J prefix before your variable)

Run test with external properties file :

jmeter -n -t test.jmx --systemPropertyFile CHEMIN_ABSOLU\config\application.properties

Script read external json and send it in body request :

import groovy.json.*;
import java.time.*;
import java.time.format.DateTimeFormatter;

def jsonSlurper = new JsonSlurper()
File fl = new File('${urlPassage}')
def obj = jsonSlurper.parse(fl)
def DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
def LocalDateTime now = LocalDateTime.now();
obj.email = now.format(formatter)
log.info new JsonBuilder( obj ).toPrettyString()
log.info 'mail send : '+obj.email
vars.putObject("passage", new JsonBuilder( obj ).toPrettyString())

with variables

passage : ${__P(passage)}
urlPassage : ${__P(urlPassage,C:/Users/imad/Desktop/passage.json)}
baseDir : ${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();)}${__BeanShell(File.separator,)}
def uri = vars.get("baseDir").concat(vars.get("urlPassage"));
File f1 = new File(uri)

Create JMeter job in jenkins

...