Suppose I have before hook at the beginning of describe block, where GET API is called to return array of some objects if data is present in database, otherwise it returns empty array.
First it block under describe is ok, it will check response status and should pass if status is equal to 200. (no matter if response array is empty or array of objects)
But second it block should check the structure of single object in array. So, if array is not empty, everything is ok, but if there is no data and API returns empty array, it will fail. How can I invoke it conditionally, only if response.array is not empty?
Related
I am trying to assign the value of this stucture path to a fieldsymbol, but this path does not work because it has a table in it's path.
But with in the debugger this value of this path is shown correctly.
Is there a way to dynamically assign a component of a table line to a fieldsymbol, by passing one path?
If not then I will just read the table line and then use the path to get the wanted value.
ls_struct (Struct)
- SUPPLYCHAINTRADETRANSACTION (Struct)
- INCL_SUPP_CHAIN_ITEM (Table)
- ASSOCIATEDDOCUMENTLINEDOCUMENT (Element)
i_component_path = |IG_DDIC-SUPPLYCHAINTRADETRANSACTION-INCL_SUPP_CHAIN_ITEM[1]-ASSOCIATEDDOCUMENTLINEDOCUMENT|.
ASSIGN (i_component_path) TO FIELD-SYMBOL(<lg_value>).
IF <lg_value> IS NOT ASSIGNED.
return.
ENDIF.
<lg_value> won't be assigned
Solution by Sandra Rossi
The debugger has its own syntax and own logic, it doesn't apply the ASSIGN algorithm at all. With ABAP source code, you have to use ASSIGN twice, the first one to reach the internal table, then you select the first line, and the second one to reach the component of the line.
The debugger works completely differently, the debugger code works only in debug mode, you can't call the code from the debugger (i.e. if you call it, the kernel code used by the debugger will fail). No, there's no "abappath". There are the XSL transformation objects (xpath), but it's slow for what you ask.
Thank you very much
This seems to be a rather unexpected limitation of the ASSIGN statement. Probably worth a ticket to SAP's ABAP language group to clarify whether it's even a bug.
While this works:
ASSIGN data-some_table[ 1 ]-some_field TO FIELD-SYMBOL(<lv_source>).
the same expressed as a string doesn't:
ASSIGN (`data-some_table[ 1 ]-some_field`) TO FIELD-SYMBOL(<lv_source>).
Alternative 1 for (name) of the ABAP keyword documentation for the ASSIGN statement says that "[t]he name in name is structured in the same way as if specified directly".
However, this declaration is immediately followed by "the content of name must be the name of a data object which may contain offsets and lengths, structure component selectors, and component selectors for assigning structured data objects and attributes in classes or objects", a list that does not include the table expressions we would need here.
The following code ...
splash:evaljs('document.querySelectorAll("iframe.iframe-container.js-oddset-game-iframe")[0].contentDocument.querySelectorAll("td.leftText a.eventLink").length')
... returns 8 - i.e. there are 8 nodes in the array.
However, when I then try to return the nodeList (array) directly, the result is nil? Obviously a table should be returned since an array is returned from the javascript code.
Is this a bug in Splash? Can't Splash handle access to elements in iframes? I have the --js-cross-domain-access option on too.
It is not a bug. iframes are only available when you use the render.json endpoint with the iframes=1 parameter. When you use that you cannot run a custom Lua script.
Refer to the documentation: https://splash.readthedocs.io/en/stable/api.html#render-json
And this answer: https://stackoverflow.com/a/44682917/4082726
I've added a User Defined Variables element
Then created a variable ${Parameter} with value "123456" and passed it in a GET request.
Created a second variable ${Response} with value "Invalid code 123456"
I've added a Response Assertion element
Added the ${Response} variable to the Response Assertion
When I send the request like this, everything is fine. But if I add the second variable in the value field, then an Assertion error is returned.
What I'm trying to do is to add a variable to the value field of an already existing variable:
e.g. Set the Value of the ${Response} variable as "Invalid code ${Parameter}"
How can I achieve this in jmeter?
Why are you unnecessarily making the things complex!
You can directly use the value you want to assert in the Response Assertion.
Keep as follows:
Invalid code ${Parameter}
Here, ${Parameter} value be evaluated first and checked against the response.
Just incase, if you want to use JMeter variable as value to another JMeter variable, use as follows, using ${__evalVar()}:
Invalid code ${__evalVar(Parameter)}
Note: observed that if you define both the variables in the same UDV, Parameter value is empty. So, add two UDVs and define Parameter in the first UDV and Response in the second UDV with above value.
I am setting expectations for a method that takes a single IList<> parameter.
How do I express in NMock3 the following statement:
Method XX of the mock should be called exactly once with a list object that contains exactly one item.
The solution I imagine would be something like the following:
theMock.Expects.One.Method(_ =>_XX(null)).With(***mystery-mocking-goes-here***);
Use Is.Match:
theMock.Expects.One.Method(_ =>_XX(null)).With(Is.Match<IList<string>>(l => l.Count == 1));
Explanation for Anantha Raju C
If you have a method to test _XX(T). In the With method you have to pass a T object or a matcher. Is.Match create it and need a Predicate as argument.
In this example, the Predicate will return true if the list contains only one item (l.Count == 1).
If I call
session.Load<MyDocumentClass>(ids);
Where ids is actually an empty string array, is any call to the database actually made? Or any other resource set / up consumed, like a connection or something?
If ids is an empty list, it won't query the database.
Note that this isn't a good behavior to rely on, why are you calling this with an empty list?