13377

How to check for NOT this number in SoapUI Assertion

Question:

I am writing some Soap UI tests and am trying to figure out if there is a way with regular expressions to check for a string that does not contain a specific number. In this one case I want to make sure that when I get a response that my recordCount field DOES NOT contain 0. I thought this might be easier but while I can see a way to check for a set of numbers the regular expression for not this doesn't seem to work. Probably only detects characters and not numbers.

My XML contains this:

<recordCount>0</recordCount>

What I want is something like

recordCount>[^0]

so I can make sure recordCount shows up in the response, but also check that at least the first number it finds is not a 0. Is there any way to do this?

<strong>Edit:</strong> Using SiKing's answer I just used the NotContains to look for recordCount>0 ; this covers the couple of cases where I don't look for specific data only how many records are returned and in those cases it just needs to be more than 0

Answer1:

Why does it have to be regular expression?

You can use either of the following XPath assertions, for all of which the expected result is false:

//*:recordCount = 0 exists(//*:recordCount[text()='0'])

Answer2:

Using regular expressions you could do something like that:

(?s).*<recordCount>[^0]</recordCount>(?s).*

When using regular expressions in an assertion in SoapUI, you have to take whitespace and line breaks into account. In the example code (?s).* works as a wildcard that includes all whitespace and line breaks.

Recommend

  • Exception handling as per java coding standards
  • Whats the right place for testhelper-classes? (phpunit/best practise)
  • SQL query to group by maximal sets of a column having inner consecutive distances below a threshold
  • Is it possible to define rest argument in OCaml?
  • How can I tell a form not to dispose a particular control when it closes?
  • Hash Code in SQL Server?
  • NUnit 3.0 TestCase const custom object arguments
  • Plotting line graph with factors in R
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • Read text file that is not in the main package in a runnable jar
  • Calling Worksheet functions from vba in foreign language versions of Excel
  • java inputstream
  • Can you perform a UNION without a subquery in SQLAlchemy?
  • FFmpeg Conversion Error
  • Retrieving value from sql ExecuteScalar()
  • Splitting given String into two variables - php
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Build own AppleScript numerical error handling
  • Numpy divide by zero. Why?
  • KeystoneJS: Relationships in Admin UI not updating
  • How to set the response of a form post action to a iframe source?
  • Hits per day in Google Big Query
  • Getting Messege Twice Using IMvxMessenger
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • How to get Windows thread pool to call class member function?
  • Bitwise OR returns boolean when one of operands is nil
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Checking variable from a different class in C#
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • reshape alternating columns in less time and using less memory
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Converting MP3 duration time
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal