Forum Discussion

mathare's avatar
mathare
Contributor
12 years ago

Should I use Connected Applications?

I'm in the very early stages of automating testing for a .NET application written in C# and am still feeling my way around. I am pretty sure that scripted tests rather than keyword tests are the right way forward for this project and plan to build up a library of common functions much like one would for almost any development project. However, I'm not sure how best to go about this really.



I started off with the TestComplete IDE, writing some VBSript code in there but found the IDE rather basic and annoying. Maybe I've been spoiled by things like ReSharper for Visual Studio and even the VBA code editor running behind MS Office apps but I really miss things like auto-indenting, correcting caps etc. I find with TestComplete's IDE I have to think about how my code looks/reads as much as what it actually does whereas other IDEs  I do odd bits of coding in will tidy certain aspects of the code up for me as I go along. So I started to look into alternatives and read about connected applications. It seemed like I could write all my code in the Visual Studio IDE after adding in a couple of TestComplete libraries and all would be good.



Initially this solution looked promising and I have roughed out a couple of basic functions that I can build upon but I have found that debugging the code can be a real pain. Now I am wondering if the connected application route is really the right one...



1. When should/shouldn't one use connected applications?



It's not clear at this stage how much of the application code I need to call directly. The idea is to interact with the application via the UI as much as possible (as a user would) but I am not completely ruling out the need/desire to call application code directly at some point.



I'd also hoped that by using connected applications I could encourage one or two of our developers to write some test code too. After all it would be in C# and could be written in Visual Studio - at least that was my thinking initially but now I realise that the syntax is different and that might confuse/annoy our developers.



2. What resources are there available for helping new users get started with connected applications?



I have read the TestComplete help docs in this area and had a look at the samples supplied with TestComplete but most of what I want to do doesn't seem to be covered by those examples and I find myself wanting some sort of language reference or more advanced example of  how to do certain things.



Perhaps it's also a lack of understanding on my part. Maybe I'm slightly missing the point of using connected applications. The TC help makes it sound like the ideal solution for getting developers more involved in testing: "The entire TestComplete engine is an OLE server that can be accessed through TestComplete’s user interface or run directly from your application’s code using the application’s language, classes, types and constant definitions. You can also use your development tool’s IDE, including its debugger."



We could run TC tests direct from the code, calling application code where necessary and do it all in C# in Visual Studio. Sounds perfect

but is there something I am missing?



3. I'm struggling to get to grips with the var type, any help/advice?



For example, I get a lot of red underlines in my Visual Studio IDE and the tooltips say things like:

a) Cannot apply operator '<' to operands of type 'int' and 'AutomatedQA.script.var.VarDelegate' - trying to loop over all items in a list

b) Cannot apply operator '==' to operands of type 'AutomatedQA.script.var.VarDelegate' and 'string' - trying to compare the Text property of a WinFormsObject with a known string

c) Argument type type 'AutomatedQA.script.var.VarDelegate' is not assignable to parameter type 'AutomatedQA.script.var' - writing a WinFormsObject property to the TC log e.g. Log["Message"](w["WndCaption"]);



I am currently stuck trying to programmatically work out whether a variable of type 'AutomatedQA.script.var' contains a known substring and am getting nowhere fast which is why I am questioning the whole connected applications approach.



I read somewhere that it is expected that one would port existing scripts from TestComplete rather than write test code from scratch for connected applications. Does that mean writing test code from scratch in Visual Studio is not a good idea for some reason?



So many questions - sorry.

Mat

3 Replies

  • Julia_K's avatar
    Julia_K
    SmartBear Alumni (Retired)
    Hello Mat,

    1. When should/shouldn't one use connected applications?


    The connected application feature was introduced in earlier versions of TestComplete in order to give access to the tested applications' internals. TestComplete has significantly improved since then, and now, you can get access to the applications' internals from TestComplete directly. For example, TestComplete recognizes UI elements in tested .NET applications and gives access to their native properties and methods. It also allows accessing libraries and classes of your tested .NET applications.

    Generally, the connected applications are used if –

    1. You want to create tests in your favorite IDE using its editor and debugger.

    2. You are creating tests for a third-party company and want to ship only the compiled executable file to protect your tests from unauthorized access/change.

    3. You want to implement a complex test that cannot be implemented by standard means of TestComplete, or you want to access to your tested application’s classes and objects that cannot be accessed from TestComplete.

    I read somewhere that it is expected that one would port existing scripts from TestComplete rather than write test code from scratch for connected applications. Does that mean writing test code from scratch in Visual Studio is not a good idea for some reason?


    When creating your tests in Visual Studio, you cannot use TestComplete’s Code Completion. If you are a novice at TestComplete, writing script tests in TestComplete IDE using the Code completion can be easier.

    2. What resources are there available for helping new users get started with connected applications?


    Unfortunately, we do not give information on the connected application other than the information from the “Connected and Self-Testing Applications” section of our Help system.

    Could you please specify what information you need? What language reference and what kind of advanced examples would you like to get? We will consider enhancing our Help topics.

    3. I'm struggling to get to grips with the var type, any help/advice?


    I failed to reproduce the behavior you describe. Could you please post your entire code here?

    Thanks in advance.
  • Thanks for the reply Julia.



    1. I hadn't consdidered the fact that connected applications was effectively old functionality and that TC had matured to the point where it natively handled the cases that would previously only have been possible with connected applications. Useful to know. The examples you give of when it is a good idea to use connected applications make sense and has given me some confidence that I am going down the right route as I want to (eventually) get our developers writing test code and they will want to use the Visual Studio IDE where possible. It's also possible that the tests will need to access the applications classes etc so we'd need to use connected applications for that. Good stuff.



    2. I had read the help system and had a quick play with the samples supplied along with TC and was still struggling to make headway but I don't know if that's down to my inexperience with TC, the application under test or a combination of these and other factors. I guess I was just after a bit of advice and guidance as to how to get started, general advice that could apply to any application. For example, I have found the Object Browser and Object Spy invaluable for identifying controls, examining their properties and so on. Maybe all that is needed is additional links in the existing connected applications help to point to the Object Browser help, or perhaps a brief 'getting started' section somewhere in the connected applications help section that covers things like getting information about the application under test with links to the Object Browser/Object Spy help. Or it could be that I missed these sort of help topics by jumping straight into the connected applications documentation and not spending sufficient time reading the more basic scripting help and/or watching tutorial videos in this area. Maybe I didn't spend enough time browsing the help system to see there were other topics that could have helped me (such as the reference topics outlining the support for Infragistics controls, for example)



    3. Don't worry about the var type stuff, I have cracked it after numerous Google searches finally pointed me back to another post on this forum that gave me the information I needed. It was all to do with parentheses it seems. For example, I had code such as:

    var a = w["WinFormsObject"]("splitContainer1");

    var b = a["WinFormsObject"]("SplitterPanel, "", 2);

    var licenseList = b["WinFormsObject"]("list_modules_");

    for (int i = 0; i < licenseList["Nodes"]["Count"]; i++)

    {

        ...

    }


    In this case I was trying to loop over all the nodes in licenseList and while the code seemed to compile and run as expected Visual Studio would underline "i < licenseList["Nodes"]["Count"]" in red and say "Cannot apply operand '<' to operands of type 'int' and 'AutomatedQA.script.var.VarDelegate'" and I wanted to get rid of this error. Another forum post helped me realise I need parentheses after "licenseList["Nodes]["Count"] i.e.:

    for (int i = 0; i < licenseList["Nodes"]["Count"](); i++)

    {

        ...

    }




    I have now been able to get rid off all the Visual Studio errors I was encountering previously.



    Overall I am rather more positive about the use of connected applications and the direction I am going with our automated testing. I was making frustratingly slow progress when I first posted but since then I have cracked a few of the problems and am now making steady progress. Phew!



    Thanks again for your help

    Mat

  • Julia_K's avatar
    Julia_K
    SmartBear Alumni (Retired)
    Hello Mat,

    Thank you for your feedback. We will improve our connected applications help topics to make them clearer.

    Thank you and good luck with your testing.