Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

DB Tool output

LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
Does the db tool output always come out as a string? I'm needing the value for a > numeric assertion, but it seems to only be seeing it as text content.
Tagged:

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    HI CMJ,

    The DB Tool will output query results as XML - which technically, is a string. However, if you chain outputs to the DB Tool, those chained tools will get XML formatted data - this is done so that you can chain any XML-based tool (such as XML Assertors or XML Data Banks) directly to the DB Tool.

    If you're trying to extract a value from the DB Tool's query results for a numeric comparison, you should be able to chain the XML Assertor directly to the DB Tool, run the DB Tool to populate the XML Assertor's Expected XML, then add a numeric assertion. Is this not working for you?
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    The DB Tool is to capture a count that will be used in the next Test.

    DB Tool to count fields in a database, the count is then put in an XML Data Bank.
    Test to pull data, then a numeric assertor to verify a value returned is greater than the count from the Query stored in the data bank.

    It's an awkward way of doing things to begin with. There might be an easier way to achieve what I want. I really want to say number of occurrances is greater than the count returned from the Database. Maybe there is a regular expression way to achieve this.
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    You can do this by parameterizing the Numeric Assertion against the value saved in the XML Data Bank (attached to the DB Tool).

    So your test suite would look like this:

    DB Tool (to get the count from the database)
    +-- XML Data Bank (to store the value

    Test to pull data (Messaging / SOAP Client)
    +-- XML Assertor (with numeric assertion, parameterized to the XML Data Bank value).
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    That's what I was trying to fake my way into, but it doesn't work because I'm trying to do the occurances of an element, not the value of an element.

    Basically I want the ability to do occurances of X element is >= DB Tool value.
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Hi,

    OK - I think I understand better now.
    We are currently working on a new feature where we will allow comparisons on the number of children assertion. Currently, it only allows equality checks, but we are adding >=, <=, !=, etc.
    In the meantime, until that feature is implemented and released, I have attached an example project which demonstrates a workaround. Basically, it works like this:

    In my example, I am using a Method Tool in place of the DB Tool. This is just for convenience - it does basically the same thing as yours because the value is stored in an XML Data Bank. The Method Tool returns a number (which would be the count you're checking against) and the XML Data Bank saves it.
    In the second test, I have a SOAP Client which runs a query against a service. This service will return a number of instances of an element. An attached XML Data Bank uses the XPath count() function to store the number of child elements of a particular element in the XML response.
    Finally, I use a method tool to retrieve and compare these numbers.

    I hope this helps!
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Works great, thanks! The only thing I'm going to add is a way to actually be able to see or store the count of elements in the response.

Tagged