How to test a bool field in a test codeunit

Hey guys, on the page I want to test in my test codeunit I have a bool field and I am not sure, how to test it. Is it possible to do this:

ItemCard.IsChecked.Activate();

Or do I have to write a handler function? If yes, do you know which type I have to use?

What behavior or function are you trying to test?

I would assume that you want to test, what happens when the boolean value is changed? And that you have some validation code, which has UI you need to handle?

“Activate()” just moves the “cursor” to the field/control. But you can use this first and then use .Value(TRUE) to imitate the user changing the value to true.

A handler function is only used if you are Invoking an action, of running other code which has some kind of UI that you need to handle. If it has a CONFIRM, then you need a confirm handler. If it has a message, then you need a message handler etc.

So I would assume that you want to test what happens when the boolean value is changed? And that you have some validation code, which has UI you need to handle?

Although its fine to use TestPages, then you should generally try to split your UI tests, from non-UI tests. You could just as well test the above function without a TestPage, just by using the Item record.

On the page “item card” I created a bool field. And now I would like to test, if it is true or false.

pastedimage1544542483890v2.png

If it is true, means if the user activates the field, other fields will be shown to the user. That situation I want to test. That is why I thought I could use the Activate-function.

If it is true, then nothing happens. Activate is just like activating a specific page - here you just activate the field. It’s just as if you moved to the field with the Tab. You are not pressing or entering anything here.

You need to test the Invocation of the field, if it is a field with validation code. That would be ItemCard.IsChecked.Invoke();

And then if your code contains any UI then you would need a handler, to handle that UI.

Just create the function|variable on the page (it is based on that version you use) and for each field from list which you want to hide|show set the property Visible = this variable.

When user updates check-mark use CurrPage.Update(false);

CurrPage.Update is NOT usable from from within a test codeunit.

Ok, the code does not contain any UI. So I thought I could start with something like this:

If ItemCard.IsChecked.Invoke() THEN
BEGIN
    ItemCard.Sugar.AssertEquals(True);
    ...

END; 

Here you are still testing using a TestPage = UI testing.

If the actual UI is not important for your test, then don’t use testpages, just use the record directly.

Sorry, my fault. Don’t understand about usage of the test codeunit for UI-testing (it is sounds strange a little for me).