Ask a Question

Test Case global assertions

SOLVED
LennSar
Contributor

Test Case global assertions

 Hi there,

I'd like to test a bunch of bad requests and expect the same return code for all of them. By default my "Valid Http Status Codes" Assertion is configured to only allow 200. For my bad requests however I'd like to change that within a test case to i.e. 502 or 405 or whatever. Having to edit every single request manually is very cumbersome and I was wondering whether there is any way to ease that process.

 

Thanks,

 

Lennart

4 REPLIES 4
richie
Community Hero

Hey @LennSar,

There's probably some groovy that would do this, but i'll leave that to someone else.

Are you using a single flat .xml project file or composite? If single file you could edit your project .xml file (be careful!) as ive done this before.

Or....you could rearrange the way youre testing. Rather than have multiple testcases with identical assertions, you could just have a single test request in a datasource/looped testcase.

E.g.

Testsuite
---testcase
------datasource
------Request
------datasource loop

Cheers,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

Hi @richie 

 

based on your data source / loop example I doubt we are talking about the same problem. I have several completely independet requests instead of a requests that can be adjusted using variables. So it would rather be:

 

Testsuite

--- TestCase A

------- Request A

--- TestCaseB

------- Request B

.

.

.

 

 

or 

 

Testsuite

--- TestCase A

------ Request A

------ Request B

------- .

------- .

------- .

 

I realised though that I can copy assertions from one Request to another and with what I can reduce the effort dramatically. 

Adjusting it in the xml file theoretically sure is possible but obviously we both know how much fun it is to do so 😉 

Hey @LennSar 

 

no, no - you can do what I suggest with the DataSource/Looping as long as the Assertions are identical (which is what you mentioned which is why I suggested it) i.e. you can have numerous different requests - the limiting factor is the identical assertions - they must be identical for looping tests (unless you wanna add in a lot of complicated hassle) ......which is why I always use them for negative tests as long as the response doesnt include a payload!

 

Saves time and gives you the value add of externalising your payloads (which is always desirable) allowing you to tailor your inputs and even outputs accordingly.

 

Cheers,

 

Rich

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

Hi @richie,

 

could you tell me how you do that or point me to a tutorial? I can't figure out how I can add assertions to a request using data source / loop. Do you manipulate the path of the request with the data source so that a single request becomes several requests?

 

Thanks,

 

Lennart

 

cancel
Showing results for 
Search instead for 
Did you mean: