i am using
assert.equal("payment_schema_validation_failed", 'payment_schema_validation_failed', 'pass')
i want to print custom message when both the assertion pass. Above line only display third parameter when the assertion fails
Related
I have to validate a negative scenario where there are input parameters for GET call. My requirement is when input parameters are empty it should return proper error message as define by developer. My feature file looks like this:
Feature: Validate the response
Backgroud:
* url baseURL
* header Content-Type ='application/json'
Scenario Outline:<scenarioname>
Given url
And param param1 = <param1>
And param param2 = <param2>
When method <method>
Then status <statuscode>
Then print response
Examples:
|Scenario Number|scenarioname|method|statuscode|param1|param2|
|Scenario 1|validate the response|get|200|'abc'|'xyz'|
|Scenario 2|validate the response when both the params are blank|get|400|||
|Scenario 3||validate the response when both the params are blank|get|400|''|''|
When i execute scenario 1 my code executes successfully.
When i execute scenario 2 on console i can see as 16:43:44.41 [main] INFO com.intuit.karate.Runner - waiting for parallel feature to complete.... And nothing happens
When i execute scenario 3 it executes successfully,if same scenario i execute in Soap then i get proper error message in Soap UI.
You are trying to do too much in a Scenario Outline. Just write separate Scenario-s. Please read this answer very carefully, you have fallen into the same trap: https://stackoverflow.com/a/54126724/143475
The other issues don't make sense, so
a) please try version 0.9.6.RC4 - because there were some fixes
b) follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
When a request is made and wasn't mocked I get an error: Error: Nock: No match for request but that doesn't fail the test. Is there a way to make sure no mocked requests were made?
You can catch the "no match" event from nock nock.emitter.on('no match', callback) and use the callback to trigger the error path in your test framework.
I'm following DeserializeErrorBody.java as a guide
When I use Converter<ResponseBody, Error> errorConverter, Error being a POJO class for my errors, I would get an EOFException trying to do errorConverter.convert(response.errorBody()); with the log being:java.io.EOFException: End of input at line 1 column 1 path$...
If I were to log erroBody.string() it would print the error that the server sends {"message":"Incorrect user or password"}
Moreover the error code at response.code() is 401 and the response.body() is null
Why do I get this error if the body is not null?
I was using Observable<ResponseBody> for the Retrofit interface, like I would use Call<ResponseBody> to check only response.isSuccessful().
Turns out I need to use Observable<Response<Void>> to skip the deserialization of an empty body which causes the EOFException.
I have a Java EE application that processes a bunch of messages from different interfaces. (Some of the) functional tests are performed with SoapUI.
In one of the cases I have created a SOAP VirtResponse step that receives the output of my application and checks the values in the received message. The test has the following steps:
Datasource step to load input and expected output (multiple scenarios)
JMS step to send input to application on a specific interface.
SOAP step to receive application output on another interface (no validation).
Groovy script to check results (e.g. no message received or message received with specific values). See below for the script, couldn't get it to work in between the list items.
Datasource loop to step 2.
There is a scenario (well, there are more scenarios) in which the input should not generate an output. I want to check if my application did not send an output in such a scenario.
Strategy 1:
I have added a fourth groovy step in which I validate that the result of step 3 is an empty string. To make the test pass, I had to disable the checkbox in TestCase Options that says "Fail TestCase on Error". This works in cases of happy execution of tests. However if an error does occur (e.g. the application did send a response when it was not supposed to or the application send a wrong response), the entire TestCase is set to passed (because of the checkbox) and only the specific step deep down in the logs is failed. This makes it hard to see the results of the entire test suite.
Attempted strategy 2:
Started out by adding a conditional test step that will skip step 3 based on the input. However that way I no longer validate if my application does not send a message when it is not supposed to.
What is the best way to check these kinds of scenarios?
EDITS:
The entire testcase should fail if one of the scenarios from the datasource fails. (It is not a problem if this means that some scenarios were not evaluated yet)
Groovy script:
// Get flag from datasource that indicates if a message should be received
def soapBerichtOntvangen = context.expand('${DataSourceUISBerichten#SoapBerichtOntvangen}' );
// Get the message from the previous step.
def receivedSoapRequest = context.expand( '${SOAPVirtResponse#Request#declare namespace out=\'http://application/messageprocessing/outbound/out:SendOutboundMessage[1]/Message[1]}' )
// If we don't expect a message the flag is set to "N"
if(soapBerichtOntvangen=="N"){
assert(receivedSoapRequest=="")
} else if(receivedSoapRequest!=null && receivedSoapRequest!=""){
def slurpedMessage = new XmlSlurper().parseText(receivedSoapRequest)
def messageType=slurpedMessage.MessageHeader.MessageReference.MessageType
// Get expected values from context
def verwachtMessageType = context.expand('${DataSourceOutboundCIBerichten#messageType}' )
assert(String.valueOf(messageType)==verwachtMessageType)
} else {
// Should have received a message, but none came up.
assert(false)
}
I'm running a test in Jmeter. that test sends in the end the status of the test - "success" or "fail".
I've created a 'user defined variable' that is named 'subject' and assigned it with value 'success'.
within the http requests I've put 'BeanShell Assertion' that assigns the 'subject' variable with 'failure' if the test failed:
if( (ResponseCode != null) && (ResponseCode.equals ("200") == false))
{
//Failure=true;
vars.put("subject","failure");
}
now, in the SMTP sampler I'm sending ${subject} as the subject of the mail.
the sampler doesn't recognise the variable (it is empty).
any ideas?
Can you show the screenshot of your Test Plan? I'm particularly interested in where Beanshell Assertion lives.
JMeter Assertions have their scope, i.e. given the following test structure:
Sampler 1
Assertion
Sampler 2
Assertion will be applied to Sampler 1
In case of the following test plan:
Sampler 1
Sampler 2
Assertion
Assertion will be applied to both Sampler 1 and Sampler 2
Nothing is wrong with your code, it should be setting "subject" variable in case of non "200" response code.
By the way, there is a pre-defined JMeter variable - ${JMeterThread.last_sample_ok} - which returns "true" if previous sampler was successful and "false" in the other case. It is better to use it in combination with the If Controller as Beanshell has known performance issues and can become a bottleneck in case of heavy loads.
The problem was that when using the 'Beanshell Assertion' I didn't pass it the variable - ${subject}, so when the test succeeded it was like the variable was never assigned.