516 views
in GUI Development by
I have to write a set of steps as common for multiple testcases. So that when customer screen changed I can just change only in common class only. For that I created a common test class and wrote the steps. In my actual test class , created an object of this common class and called the common function. But during execution, exception thrown as Runner value was null. Kindly help me to achieve this.

1 Answer

0 votes
by
Hi SKI,

if I understand you correct, you try to introduce the common teststeps through a dedicated class that gets instantiated inside every of your specific test cases. Instead of doing this I would recommend to create a base class where you are implementing your common test steps. Than you can derive from this class and use your common teststeps inside this derived class. This way has always worked for me.

Best regards,

Julian
by
I have created base class with type Test::Case and inherited my testcase class from this. But I got exception

Chora exception: 'Test can not be executed multiple times'.
by

This message gets printed when the steps do not have a unique name e.g.:

AddStep( "CheckMenuOpened", StepCheckMenuOpened, 500 );
AddStep( "CheckMenuOpened", StepNavigateMenuDown, 0 );

Make sure that this does not happen by e.g. introducing a variable and attach it to the name e.g.:

AddStep( "CheckMenuOpened" + string( yourVariable ), StepCheckMenuOpened, 500 );

You could for example group all your common AddStep calls inside your base class and then call it inside your derived classes. Pass the yourVariable as argument with an unique value.

Hope this helps.

by
Can we use AddStep inside a common function in base? I tried that but it didn't worked.
by
Do you stil get the Chora exception: 'Test can not be executed multiple times'. Or could you solve this with my last post?
by
The exception is solved when I given unique name for steps. Thanks.

Can we group a set of AddStep inside base class or derived class? When I tried, that steps were not executed.
by

With unique names this should work. Are you overwriting the method inside your derived class without calling super()?

https://doc.embedded-wizard.de/expressions?v=11.00#11

For slots you have to call super( sender ) to execute the base method code.

by
yes. I tried with super and not working.

Even I created a slot in derived class itself and added multiple AddSteps call in that slot. That also not working.

My EnterPassword slot looks like this.
AddStep( "EnterKeya1", EnterKeya1, 1000 );
AddStep( "EnterKeyd1", EnterKeyd1, 1000 );

when I called EnterKeya1 and EnterKeyd1 separately inside Init(), it worked.

But if calling multiple AddSteps inside a slot (like EnterPassword  slot), and using that slot inside Init(), it is not working.
by

But if calling multiple AddSteps inside a slot (like EnterPassword  slot), and using that slot inside Init(), it is not working.

Are you calling this slot inside Init() multiple times?

Can you please send me some code snippets of the slots and methods you are using?

by

CommonFunction

Init

Please find the common slot and Init function in my testcase class.

by
Ok, the problem is, that you trying to add a teststep within a teststep which is not possible. Teststeps needs to be defined before the execution of them starts. You can do the following: Your common base class can contain a method that contains the AddStep() calls. Than call this method inside your derived class inside Init(). If you want to call this method multiple times inside the Init() than you can introduce a parameter at this method and construct from this the name that you set at those AddStep() calls (see my second comment).
by

1. I created a common method "EnterAdminPassword" containing AddStep() calls in base class and tried to call this inside derived init method without overriding in derived class. but I got following error

Error Tests::TC1_SetupAdminPassword.Init (10:32) : Unknown identifier 'EnterAdminPassword' found.

2. Then I override the method by calling super(). But then also I got same error. If using super(sender);, getting error "Unknown identifier 'sender' found."

3. So I created a slot in derived class and called the overrided method EnterAdminPassword inside the slot. But that time, the AddStep is not worked. In AddStep calls I have given SendTouchEvent().

Can you please confirm BaseCommonMethod . here EnterKeya and EnterKeyd are slots inside base class.

Can you please help to follow the proper approach.

by

Your BaseCommonMethod looks fine. No need to overwrite this inside your derived calls. Are you calling this inside your derived class Tests::TC1_SetupAdminPassword.Init() like:

AddStep( "SomeOtherStep", onSomeOtherStep, 1000 );
EnterAdminPassword();
AddStep( "SomeOtherStep2", onSomeOtherStep2, 1000 );

 

by
Sorry. I called AddStep( "EnterAdminPassword", EnterAdminPassword, 1000 ); inside derived Init.

Now I corrected and working fine.

Great thanks for your time and support.

Embedded Wizard Website | Privacy Policy | Imprint

...