Validations not throwing a validation exception

Ask general questions here.
jjorgens
Posts: 14
Joined: Wed Apr 01, 2009 7:32 pm

Validations not throwing a validation exception

Post by jjorgens » Thu Jul 18, 2013 4:54 pm

The validation class is not throwing a validation exception when the validation fails.

Example:
This is an example when the validation is expected to succeed. This is working how I would expect it.
PS C:\Users\jared>

Code: Select all

 [Ranorex.Validate]::AreEqual(1,1) 

[2013/07/18 09:19:00.346][Success][Validation]: Objects are equal (actual='1', expected='1').

This is an example when I force it to fail:
PS C:\Users\jared>

Code: Select all

 [Ranorex.Validate]::AreEqual(2,1)

[2013/07/18 09:19:04.086][Failure][Validation]: Objects are not equal (actual='2', expected='1').
Exception calling "AreEqual" with "2" argument(s): "Objects are not equal (actual='2', expected='1')."
At line:1 char:29
+ [Ranorex.Validate]::AreEqual <<<< (2,1)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException



I am running these examples from powershell which is why I am using the syntax [Ranorex.Validate]::AreEqual(). Why is this throwing a MethodInvocationException rather than a validation exception? I am using this simple example with comparing two numbers but it behaves this way on any validation I do with actual elements.

System Info:
[2013/07/18 09:25:58.773][Info ][SystemSummary]: Host: computer.test
Ranorex version: 4.0.3.22982
OS version: Windows 7 Service Pack 1 64bit
OS default locale: en-US
.NET Runtime version: 4.0.30319.18052
Number of logical CPUs: 4
Number of displays: 2
Screen dimension: 3840x1200
Memory: 60% load, phy 3219mb free/8181mb total, virt 1732mb free/2047mb total.

Thanks,
Jared

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Validations not throwing a validation exception

Post by Support Team » Fri Jul 19, 2013 3:02 pm

Hello,

Do you get the same exception if you run the <TestSuite>.exe using command line?
In general, we throw a validation failure message if validation fails:
[2013/07/18 09:19:04.086][Failure][Validation]: Objects are not equal (actual='2', expected='1').
Exception calling "AreEqual" with "2" argument(s): "Objects are not equal (actual='2', expected='1')."
It looks like that the other exceptions are thrown if you use PowerShell.

Regards,
Markus (T)
.
Image

jjorgens
Posts: 14
Joined: Wed Apr 01, 2009 7:32 pm

Re: Validations not throwing a validation exception

Post by jjorgens » Wed Jul 24, 2013 7:14 pm

My test suite is not an .exe, it is a ps1 powershell script. I am not sure what you mean, do you want me to create an .exe test suite and run it from cmd.exe?
All the other Ranorex functions I run work perfectly in powershell just not this validation.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Validations not throwing a validation exception

Post by Support Team » Thu Jul 25, 2013 3:52 pm

Hello,

In general, a solution in Ranorex Studio or Visual Studio creates a binary file (*.exe) of a Test Suite after compiling. This file will be used to run a test using command line (cmd.exe).
If you create a validation, the report should only show the message attached.
Other exceptions seem to be related with Power Shell only.

Regards,
Markus (T)
Attachments
ValidateError.PNG
ValidateError.PNG (39.99 KiB) Viewed 1311 times
.
Image