BaseWebAiiTest inherit

6 posts, 1 answers
  1. Jonas
    Jonas avatar
    20 posts
    Member since:
    Jun 2012

    Posted 28 Nov 2011 Link to this post

    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
  2. Answer
    Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 01 Dec 2011 Link to this post

    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.
  3. aplicaciones
    aplicaciones avatar
    22 posts
    Member since:
    Apr 2017

    Posted 02 Nov in reply to Stoich Link to this post

    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,

  4. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    655 posts

    Posted 06 Nov Link to this post

    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
     
  5. aplicaciones
    aplicaciones avatar
    22 posts
    Member since:
    Apr 2017

    Posted 09 Nov in reply to Elena Tsvetkova Link to this post

    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
  6. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    655 posts

    Posted 10 Nov Link to this post

    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
     
Back to Top