Report failure if both previous tests fail, otherwise report success

Testing a simple search API with same endpoint different parameters - the first search pulls back "fast results" based on keyword search, the second search pulls back "AI results". I want to create a test that only fails if neither the "fast search" or the "AI search" returned the correct link (href) as the first link in the response. I created the first test which fails if the first href in the response is not the correct url - called "Fast Search". Similarly, I created the second test called "AI Search". How do I create a third test that fails if both Fast Search and AI Search fail?
Answers
-
How do I create a third test that fails if both Fast Search and AI Search fail?
You can configure tests to execute conditionally based on the pass/fail status of previous tests. So, you could add a third test that only executes and fails if the first two fail. See Test-Specific Logic Options.
What type of test you create is up to you. It could be an Extension tool with a simple script:
void fail(def input, def context) { context.report("Fast Search and AI Search failed!") }
0 -
Otherwise, you can always use data banks to extract the "hrefs" and make your third test compare them again. You can also access data bank columns from scripts using
context.getValue("Generated Data Source", "columnName")
.I would recommend you post your question to Parasoft IDA (the AI chatbot in the corner of this page). It happens to provide a bit of step-by-step detail to doing it this other way.
0 -
Thanks, I decided to go with the second option - making a third test to compare the two values from Test 1 and Test 2 that were written to the XML databank. IDA got me in the right direction, but can't seem to help me with the error I'm getting (see attached). According to IDA, I need to unlink the data source from the Extension Tool but the UI will not allow me to blank that field out. Any ideas besides going into the .tst file and editing it by hand?
0 -
You have a couple problems:
- Notice the "Error message" that says "global variable 'context' does not have a value."
- Notice the "Method" combo has nothing selected.
In SOAtest, your script must define a function or method. In this context, the function must take "0, 1, or 2" arguments as you see in the label shown next to the "Method" box. One of the arguments to your method would be the "context" object. Please see Extensibility and Scripting Basics which shows some examples.
Also, please recall that you access data bank columns from scripts using context.getValue("Generated Data Source", "fastHREF"). You must use the special string "Generated Data Source" followed by the name of the custom data bank column.
0