Last active
August 29, 2015 14:18
-
-
Save smarigowda/4cdb0b424b5f52bc5d70 to your computer and use it in GitHub Desktop.
JMeter Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- run only once for each thread | |
if( ${__counter(TRUE)} == 1 ){ | |
print("MyPrint :: This is run once per thread" ); | |
} | |
-- if condition can take a variable | |
-- ex ${any_variable} | |
-- JSR223 Post Processor | |
-- user of vars.get and prev | |
-- prev is predefined in JSR223 Post Processor | |
-- prev gives access to the previous SampleResult | |
-- you can use prev to set the transaction state to PASS or FAIL | |
if(vars.get("SUCCESS").equals("true")) { | |
prev.setSuccessful(true); // no error | |
// print("MyPrint :: PreTest - PERSONALISE_DOCUMENT_REQUEST STATUS = SUCCESS"); | |
} else { | |
prev.setSuccessful(false); // some error | |
print("MyPrint :: PERSONALISE_DOCUMENT_REQUEST STATUS = FAIL"); | |
print("MyPrint :: Failed Response Data = " + prev.getResponseDataAsString()); | |
print("MyPrint :: Failed Response Message = " + prev.getResponseMessage()); | |
print("MyPrint :: Failed Response Code = " + prev.getResponseCode()); | |
} | |
-- Test Action | |
-- Test Action is used as conditional controller | |
-- Can be used to PAUSE or STOP current/ all threads based on a condition | |
-- if PAUSE then you can provide how long to pause in milli seconds | |
-- For variable delays, set the pause time to zero, and add a Timer as a child. | |
-- SYNC Timer | |
-- Synchronizing Timer | |
-- It can create large instant loads at various points in of the test plan | |
-- | |
-- __counter function and it use | |
-- if TRUE it creates counter for each thread | |
-- if FALSE it creates global counter | |
if $(__counter(FALSE) == 1) { | |
// this gets executed only once for all threads | |
} | |
if $(__counter(TRUE) == 1) { | |
// this gets executed once for each thread | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment