I have added bean shell assertion in my scripts.
It shows the failure message for all the cases, even if it passed.
Below is my scripts
String response = new String(ResponseData);
if(${BoolValue} == true)
{
Failure = !(response.contains("growth"));
FailureMessage = "Projection values is showing in the response data for non-skill reports";
}
if(${BoolValue} == false)
{
Failure = (response.contains("growth"));
FailureMessage = "Projection values is not showing in the response data for skill reports";
}
I need to get Failure Message only if the case gets failed. Please let me know, how to do this?
Check Failure before Failure Message assignment:
String response = new String(ResponseData);
if(${BoolValue} == true)
{
Failure = !(response.contains("growth"));
if (Failure) {
FailureMessage = "Projection values is showing in the response data for non-skill reports";
}
}
if(${BoolValue} == false)
{
Failure = (response.contains("growth"));
if (Failure) {
FailureMessage = "Projection values is not showing in the response data for skill reports";
}
}
BTW use should probably use Java conventions of variable name should start with lowercase letter as: failure
instead Failure
.