Forum Discussion

motorola's avatar
motorola
Contributor
13 years ago

the effect of scripts in test

when
recording the test, testcomplete automatically creates the sequence of
activities recorded during the test, so why do we need the scripts? how
does changing scripts affects the course of the test and vice versa? if I make changes in keyword test steps, will the script be adjusted automatically? how about the inverse? thank you

10 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Scripts are tests.  It sounds like you are making a comparison between keyword tests and script code tests.  They are two means of doing the same thing, that being indicate a sequence of events, actions, etc., to execute against your AUT.  It's just a matter of the means.  So, re-ordering "scripts" will actually change the test when you run the altered scripts.  But if you export a keyword test to scripts, you're actually creating a copy of the test.  You now have a test written as a keyword test and a test written as script code.  Altering the script code will not change the keyword test and vice versa.



    Is this what you're asking?  Or is there something I'm missing here?
  • okay, by default if I record a test, script will not generated by testcomplete, correct? I must specifically order testcomplete to generate script, only then will the script exist, right? after the script is generated like previously mentioned, is it guaranteed that the script and the keyword test always in sync? based on your explanation, they become like separated instances. If I change the script only, then the script won't reflect what's done by keyword test. is this correct?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Correct, essentially, on all points.  Script code and Keyword Tests are two methods of creating tests to execute.  Script code can be generated from Keyword tests but changing the one does not "synch" with the other.  They are two seperate items.



    As for "by default", not necessarily.  When you go to the "record" button, there's actually a drop down that you can select to record a keyword test or record script code.  You can choose either way of recording at any time.  I believe the project remembers the last record method used,



    Why have two different ways?  Easy: Not everyone can write code.  So, TestComplete provides keyword tests for automated testers who wish to create tests but do not have a code skill set.  



    Personally, I prefer script code over keyword tests but keyword tests are good and useable for certain things.  More complicated logical stuff may require the writing of script code.  But you can call script code from keyword tests and vice versa.
  • so lets say right now I have script and keyword code, how do I know which version of test I run? here's my assumption:

    if I right click on script and select run, that means script test. however if I right click on keyword test and run, that means keyword test. Is that about right?
  • and what if i right click on the project name and run, which test will be run? script or keyword?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    That's correct, as you're working on developing tests.  You can use Test Items within the project to, when you say "Run project" to specify which test to execute.



    Again, there is no direct relationship between a script test and a keyword test.  They are two separate entities.  If you want to run the script test, you need to specify so within the project.  If you want to run the keyword test, you need to specify so.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    That's correct, as you're working on developing tests.  You can use Test Items within the project to, when you say "Run project" to specify which test to execute.



    Again, there is no direct relationship between a script test and a keyword test.  They are two separate entities.  If you want to run the script test, you need to specify so within the project.  If you want to run the keyword test, you need to specify so.
  • sastowe's avatar
    sastowe
    Super Contributor
    Your questions is:



    "so why do we need the scripts?"



    Let me see if I can answer this for you. I am not sure if I am going to give you the answer you want. But here goes.



    In my opinion, using Test Complete in a record and playback manner is not using the tool to its fullest potental AND has some drawbacks.



    When recording a test, the object that TC records in not recognizable at playback time. By writing some code, I can intelligently handle the acquisition of the correct object. (There may be mechanisms for doing this in keyword testing. I know next to nothing about keyword testing.)



    Furthermore, I can make robust tests by designing script routines that can be reusable, test more than one thing... For example, I have a high risk area of the system in which users can perform a set of actions on some selections. I have several procedures

    - GetStartingState

    - UserPerformsSelection

    - UserPerformsAction

    - DoComparetoExpectedResults



    In each case, the selection, desired action and expected results are all stored in an Excel spreadsheet that drives (see DDT) the tests. I can very quickly create new tests across a wide variety of selections and actions and compare the data to the expected result. When we develop new actions, I can very quickly create new tests to test those actions...



    Hope that helps / addresses what you wanted to know.
  • yes, it makes sense script test is a lot more flexible and powerful than keyword test, but I have a question, what about the object mapping? lets say I want to capture all objects in a form, it would be too cumbersome to handwrite the namemapping right? and the aliases. this is an important piece I need to know. thanks
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    NameMapping is universal and is not something you "hand write" as a script or a keyword test.  It's an object/project item that is simply part of a TestComplete project.  NameMapping can happen automatically while recording (keyword or script) or (and I do this more often than recording), you can manually map specific objects using the various methods.  Read up on NameMapping to find all the different ways you can map objects.