This is a migrated thread and some comments may be shown as answers.

BaseWebAiiTest inherit

5 Answers 141 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonas
Top achievements
Rank 2
Jonas asked on 28 Nov 2011, 04:32 PM
Hello,

I'm trying to make a class inherit for the BaseWebAiiTest class.

I've have a GlobalFunc.cs file where i store all my methods that can be used for everything, like LogMessage etc.
And i don't wanna make a new GlobalFunc each time. So i made a new class. Procedure that inherits from BaseWebAiiTest

public class Procedure : BaseWebAiiTest

{

protected Lazy<GlobalFunc> globalFunc;

 

public Procedure()

{

globalFunc = new Lazy<GlobalFunc>(CreateGlobalFunc);

}

private GlobalFunc CreateGlobalFunc()

{

return new GlobalFunc(Log);

}

}



In one of my currect tests called CreateChartOfAccounts that inherits from Procedure (Procedure inherits from BaseWebAiiTest)
But when i'm doing this all of my steps dissappear and i get a error when i try to run.

    public class CreateChartOfAccounts : Procedure

    {

    [CodedStep("Test Monkey")]

    public void Monkey_test()

    {

       globalFunc.Value.LogMessage("Hello world");

    }


Error message :
System.ArgumentException: String cannot have zero length.


Is it possible to inherit from in my case Procedure? Or how shall i solve this?

[EDIT : Added attached files]

Best Regards
//Jonas

5 Answers, 1 is accepted

Sort by
0
Accepted
Stoich
Telerik team
answered on 01 Dec 2011, 09:19 AM
Hello Jonas,

I was easily able to reproduce this as seen in the following video:

http://screencast.com/t/llhTbncS9

Basically when you change the inherited class, Project view will no longer recognize that this class is a code-behind class associate with a particular test.

By default when Test Studio generates a code-behind file it always has the exact same name as the test it’s associated with. It turns out that it always has to inherit one specific class: BaseWebAii test. Any deviation from this causes the class not to be recognized as a code-behind file.

In the guys from Sitefinity’s usecase they change the inherited class. The code-behind file is lost and any coded steps added to the test immediately disappear (see video). Now when they try to add a new coded step Test Studio attempts to create the code-behind class with the exact same name as the test. However, a class  with this name already exists in the project – the previous code-behind class with the altered  “inheritance”. Thus the error you’re getting occurs.

At the moment you simply can’t change the inherited class. Instead I suggest that you use a “Utility” class/project. We have a sample project that demonstrates this approach here:

http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/use-external-dll.aspx


Best wishes,
Stoich
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
aplicaciones
Top achievements
Rank 1
answered on 02 Nov 2017, 09:26 AM

Hello,

I have the same scenario. I need to create my custom Base Class  as I encapsulating a lot of common functionality  inside of it. My Base Class inherits from BaseWebAiiTest. So, the same thing happens: all my coded steps are no longer recognized.

As this post is from 2011 I would like to know if there is any improvement on this?
On the other hand, all the links in the reply above are no longer valid. Could you update them so for instance I could se the "Utility" class/project.

Best regards,

0
Elena
Telerik team
answered on 06 Nov 2017, 03:33 PM
Hello,

Thank you for reaching us out. 

As you mentioned you are referring to a post from 2011. Of course there are plenty of improvements since then. Though I will certainly need some further details to better understand the current issue you are facing. 

I guess it will be helpful to you to review how you could implement a standalone code file which is the alternative of an external dll. Please let me know if this is would be applicable for your scenario. Alternatively please share details about your requirements. Thanks! 

Regards,
Elena Tsvetkova
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
aplicaciones
Top achievements
Rank 1
answered on 09 Nov 2017, 05:46 PM
Hello,
Thanks for your answer but that's not precisely what i was looking for.

Anyway I have found the answer in this post:
https://docs.telerik.com/teststudio/troubleshooting-guide/visual-studio-tg/coded-steps-disappear-vs

Regards
0
Elena
Telerik team
answered on 10 Nov 2017, 02:52 PM
Hi,

Thanks for the feedback. I am glad to know you managed to find what you have missed. 

Regards,
Elena Tsvetkova
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Jonas
Top achievements
Rank 2
Answers by
Stoich
Telerik team
aplicaciones
Top achievements
Rank 1
Elena
Telerik team
Share this question
or