Extracting a value from JSON with JMeter

So again an issue I had and thought I’d share. I found very little about this on Google. The problem I had was, that I got a JSON response from a site that contained an ID I’d need to use on the next page. The challange was that I had a variable in the regex which JMeter doesn’t seem to like. The easiest way to do this is to use JMeter-plugins!!!

Short post, if it were not for the unlucky fact that I couldn’t use the plugins. So here the long answer….

Continue reading

Iterating over a CSV file in JMeter

A common problem in JMeter is that you want a CSV file as an input and want to execute each line, then continue. So from a script perspective that would look something like this:

Thread Group
 |-For Each CSV Line
 |  |-HTTP Request (CSV input)
 |-Do something else

The issue though is there is no “For Each” concept in JMeter. I know that it is called a ForEach Loop in JMeter but it isn’t from a developer view. You need to know the length of your CSV file. You could just tell the For loop how many lines there are but that would make it very unflexible. You’d need to adjust the script every time the CSV changes.

So here is how I solved it. Not elegant but it actually works quite well.

Continue reading

KWST 2015

Just a follow up on the 2015 Kiwi Workshop on Software Testing (Aug 2015). Find my write-up here:

http://www.associationforsoftwaretesting.org/2015/10/11/grant-program-kwst2015/

KWST 2015

In attendance this year were:
James Bach, Oliver Erlewein, Richard Robinson, Aaron Hodder, Sarah Burgess, Andy Harwood, Adam Howard, Mark Boyt, Chris Priest, Mike Talks, Joshua Raine, Scott Griffiths, John Lockhart, Sean Cresswell, Rachel Carson, Till Neunast, James Hailstone, David Robinson and Katrina Clokie

by
Oliver Erlewein

Loading File Contents Into a JMeter Variable

Sorry for the ongoing spam about JMeter stuff but I am writing a LOT of coding at the moment and I thought I’d share some of the knarly stuff I come accross so others might benefit.

So I had the issue that I need to cobble together MIME HTTP/SOAP calls that contain attachments. JMeter has the ability to add files statically to an HTTP Request (Body Data) but if you need more control you need to roll your own. Best way to do this would be to load the file into a variable and just attach like this:

...
--MIME_boundary
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <MyFile.pdf>
Content-Disposition: attachment; name="MyFile.pdf"

${AttachmentFile}
--MIME_boundary--
...

But how do you get it into the variable?

Continue reading

HMAC and SHA256 in JMeter

Some projects require authentication features that involve some quite intricate steps. But fret not, in JMeter we can use Groovy to do the heavy lifting. Below is a very simple example of how you can do a HMAC encryption. It also includes the SHA256 hashing and base64 encoding. The only thing missing are the functions to read the variables from JMeter and publish the hash to JMeter but that is trivial and you can fit it into whatever you already have scripted.

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;

String secretKey = "secret";
String data   = "Message";

Mac mac = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA256");
mac.init(secretKeySpec);
byte[] digest = mac.doFinal(data.getBytes());
encodedData = digest.encodeBase64().toString();
log.info("HMAC SHA256 base64: " + encodedData);

by Oliver Erlewein

 

KWST 2014

A late report from our workshop last year. I stumbled across it again in my preparations for KWST (Kiwi Workshop on Software Testing) 2015. It was supposed to be published through our gracious sponsor, The Association for Software Testing (AST), but it never eventuated. So I thought I’d post it here. Better late than never.

So here goes….

For the fourth year in a row, Wellington (New Zealand) has successfully hosted the Kiwi Workshop on Software Testing. The two-day intensive testing workshop is one of the key drivers of the Context-Driven Testing (CDT) community Down Under.

In its beginnings, the aim was to give the experienced and senior community members a platform to drive innovation and exchange ideas. The impact of KWST in the community over these past years has had far reaching effects in New Zealand as well as Australia.

Workshops, conferences, and magazines have emerged since, which have lifted the game right across the board. KWST 2014 was specifically aimed at involving new faces in the community and not drawing as much on the established KWST crowd.

The topic this year was:

“How to speed up testing? – and why we shouldn’t”

Continue reading

JMeter and Controlling HTTP Keepalives

jmeterThreading and keepalives in HTTP are always an issue in performance testing and testing tools. When does a keepalive session start and how many are started is a thing of mystery. So having a bit of clarity helps. On my current project I wanted to prove what thread connects to what server for how long.

Continue reading

Test Metrics Debunked – Coverage (2/5)

chart-coverageThis is the second in our series on metrics. We started with a discussion on residual risk (here) and now move on to coverage.

Coverage can be measured in dozens of different ways. For example we can look at functional coverage, requirements, architecture and risks. We could also look at code coverage or database coverage. But as a testing metric they are weak. They all have the same fallacy at their core.

Test coverage metrics ignore the actual quality of what was done. Did we actually cover some feature/code or just touch it? I could cover a piece of code with one test, showing it as tested but there might be a hundred different data constellations that would be relevant to that part of the code. Each one might cause it to fail. Coverage is not guaranteed to answer those questions.

So….

Continue reading

CITCON Auckland 2014

So, CITCON Auckland (http://www.citconf.com/) is over and what a blast it was!

What I really like about this conference is, that there is such a diversity of people coming to it. It is not the usual siloed Dev/Test/BA/… type conference but attendees come from all over. That means the know-how is totally diverse, as are the topics. And these were the topics (click on the pic to get the full res version): CITCON_AKL_Program

 

Continue reading

Rex Black on how to recognise a CDT tester [Updated]

We’re often in a spot, where we have to interview testers for a position. We also get interviewed ourselves. So as someone who considers himself aligning to CDT, how do you recognise who you have in an interview?

Over the years I’ve developed my own style and it gets me usable results but Rex Black and Michael Bolton have put it so nicely into this FaceBook post I really can’t resist posting it here. It makes the point so well I couldn’t possibly add anything more to it.

So if you ever wondered who you are or what a CDT tester interview looks like…

Continue reading