Poobury
12 years agoNew Contributor
No setter for HTTP Statuses in ValidHttpStatusCodesAssertion
Hi All,
I'm trying to programmatically add a test step to a test case, and I'm having trouble adding assertions to the test step. The problem is that ValidHttpStatusCodesAssertion[/font:25njtky8] doesn't have a setter or getter for the codes[/font:25njtky8] attribute. For example:
The problem is with the last assertion, in that I need to call assertion.setCodes("200,404")[/font:25njtky8], but, as I say, the class doesn't have a setter for that.
I'm going to try and work around it using reflection, but I thought I'd raise it as an issue, as I'm sure it's just an oversight and not intentional, as it is inconsistent with how the other assertions work.
Many thanks to all for your efforts!
Paul.
I'm trying to programmatically add a test step to a test case, and I'm having trouble adding assertions to the test step. The problem is that ValidHttpStatusCodesAssertion[/font:25njtky8] doesn't have a setter or getter for the codes[/font:25njtky8] attribute. For example:
// Add our script assertion.
def assertion = newTestStep.addAssertion(GroovyScriptAssertion.LABEL)
assertion.setScriptText('log.info("Test Worked")')
// Check the response time
assertion = newTestStep.addAssertion(ResponseSLAAssertion.LABEL);
assertion.setSLA("200")
// Check the HTTP Status Code
assertion = newTestStep.addAssertion(ValidHttpStatusCodesAssertion.LABEL);
The problem is with the last assertion, in that I need to call assertion.setCodes("200,404")[/font:25njtky8], but, as I say, the class doesn't have a setter for that.
I'm going to try and work around it using reflection, but I thought I'd raise it as an issue, as I'm sure it's just an oversight and not intentional, as it is inconsistent with how the other assertions work.
Many thanks to all for your efforts!
Paul.