1
votes

I have a simple API upload, it is used to accept upload file from client.

var flg=true;
app.post('/test', function(req, res){
flg=!flg;
var returnJson='{';
if(flg){
    req.form.on('part', function (part) {
        if(part){
            part.resume();
        }
        returnJson=returnJson+',\"status\":\"0\"}';
        res.send(returnJson);
    });
}else{
            console.log('close');
    returnJson=returnJson+',\"status\":\"1\"}';
    res.header('Connection', 'close');
    res.send(413, returnJson);
}
 });

I'd like to test this API with Jmeter. "status":"0" means success. "status":"1" means failure. I write Jmeter script like this: http://i.imgur.com/vEUJKc8.jpg

Jmeter only displays all the samplers which response contains "status":"0". it seems Jmeter exclude failure sampler response which comes from else section. http://imgur.com/bkFSpK2

How can I see all samplers which includes all success and failure samplers in Jmeter? successful Sampler result is : Thread Name: API 1-1 Sample Start: 2013-12-18 11:46:08 PST Load time: 7 Latency: 6 Size in bytes: 178 Headers size in bytes: 163 Body size in bytes: 15 Sample Count: 1 Error Count: 0 Response code: 200 Response message: OK

Response headers: HTTP/1.1 200 OK X-Powered-By: Express Content-Type: text/html; charset=utf-8 Content-Length: 15 Date: Wed, 18 Dec 2013 19:46:08 GMT Connection: keep-alive

HTTPSampleResult fields: ContentType: text/html; charset=utf-8 DataEncoding: utf-8

Any suggestion?

1

1 Answers

2
votes

I don't like this stanza:

 ContentType: text/html;

Correct ContentType for JSON will be application/json

You can try using HTTP Header Manager to set Content-Type header of your request to be application/json and see what happens.

Also there is a JSON plugin which provides JSON Path Extractor and JSON Path Assertion (Select “Extras with libs set” from the download list).