Validate.Equals() is always true

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
andrii.savka
Posts: 12
Joined: Mon Mar 30, 2020 2:10 pm

Validate.Equals() is always true

Post by andrii.savka » Mon Apr 19, 2021 6:08 pm

Hi!

I have a strange thing.
we have such conditions:
bool isContaines = true;
bool actualResult = false;

When I'm using this code Validate.Equals(isContaines, actualResult); - validation is always successful :o :shock: :?: .
I used this validation as workaround Validate.IsTrue(actualResult.Equals(isContaines)); - this works fine.

Is it normal?

P.S. Ranorex 9.3.1

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6544
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Validate.Equals() is always true

Post by odklizec » Tue Apr 20, 2021 8:26 am

Hi,

I'm guessing you expecting that the Validation step will actually fail test? But that's not the purpose of this method! This method simply returns 'true' or 'false'. So if you want it to actually fail the test, you must add some steps ;)

Something like this should do the trick:

Code: Select all

bool isContaines = true;
bool actualResult = false;
if (Validate.Equals(isContaines, actualResult))
{
    Report.Success("Success", "success msg");
}
else
{
    Report.Failure("Failure", "failure msg");
}
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

andrii.savka
Posts: 12
Joined: Mon Mar 30, 2020 2:10 pm

Re: Validate.Equals() is always true

Post by andrii.savka » Tue Apr 20, 2021 6:38 pm

Okay, I got it, thanks!