51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 3601|回复: 0
打印 上一主题 下一主题

《Made easy Testcomplete》- Digest

[复制链接]
  • TA的每日心情
    奋斗
    2015-11-17 09:09
  • 签到天数: 7 天

    连续签到: 1 天

    [LV.3]测试连长

    跳转到指定楼层
    1#
    发表于 2009-1-24 16:34:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    1. Part of TC-IDE introduction:
    1) Object Browser- Properties: The blue clolor arrow means those properties are Read-Only;
    2) No arrow means Written, it is a the title of the window.You can push <CTRL> key and Click the mouse inside of the edit area of the property, and to modify.
    3)Object Browser- Method:The green color narrow means the method used by the object;

    2.Parts of ShortKeys:
    Code Complete:
    CTRL+Space;
    Parameter Complete:
    CTRL+Shift+Space;
    Add/Delete Bookmarks:
    CTRL+SHIFT+Num(1-9);
    Insert code template:
    CTRL+J;

    3.Special characters in vbscrīpt:
    chr(13)/[Enter]   回车  
    chr(10)     换行
    Chr(65)     返回   A  
    Chr(97)     返回   a  
    Chr(62)      返回   >  
    Chr(37)      返回   %

    4. TestComplete supports FIVE types of Unit Testing:
    DUnit,JUnit,MSTest,NUnit,TCUnitTest.

    5.Checkpoint types in Testcomplete (12):
    XML Checkpoint,
    File Checkpopint,
    Object Checkpoint,
    Property Checkpoint,
    Web Service Checkpoint,
    Web Accessibility Checkpoint,
    Web Comparison Checkpoint,
    Table Checkpoint,
    Region Checkpoint,
    Database Table Checkpoint,
    Clipboard Checkpoint,
    Manual Checkpoint,
    wait for object

    6.Data Driven Plug-In(DDT) in TestComplete:
    1)(It uses ADO to access different data elements, such as a text files,Excel Spreadsheets or any ADO compatible database.)
    These methods/properties below are provided:
    ColumnCount,
    ColumnName,
    Name,
    Value,
    EOF,
    DriveMethod,
    Next
    2)DDT plug-in supports the creation of three different types of drivers:
    CVSDriver,
    ExcelDriver,
    ADODriver
    3)DDT uses method often:
    DDT.CSVDriver(Files.FileNameByName("TestData.txt"))
    DDT.CurrentDriver.DriveMethod("Unit1.Test1")
    edit..keys(DDT.CurrentDriver.Value("ColumName of the TestData.txt"))

    Note:DO NOT TOUCH THE COMPUTER WHILE THE TEST IN RUNNING.
    how to modify a scrīpt to get values from the DDT driver,e.g.:

    'Main
    Sub Main
    DDT.CSVDriver(Files.FileNameByName("TestData.txt"))
    DDT.CurrentDriver.DriveMethod("Unit1.Test1")
    End Sub
    [Jscrīpt]
    function Main()
    {
    DDT.CSVDriver(Files.FileNameByName("TestData.txt"));
    DDT.CurrentDriver.DriveMethod("Unit1.Test1");
    }

    'Unit - Sub Test1
    Sub Test1
    Dim w1
    Dim w2
    Log.AppendFolder(DDT.CurrentDriver.Value("case"))
    Set w1 = Sys.Process("All Pairs Sample").MainForm
    w1.WinFormsObject("trackBar1").wPosition =
    DDT.CurrentDriver.Value("Iterations")
    Call w1.WinFormsObject("comboBox2").
    ClickItem(DDT.CurrentDriver.Value("Stores"))
    Set w2 = w1.WinFormsObject("comboBox1")
    Call w2.ClickItem(DDT.CurrentDriver.Value("Strategy"))
    w1.WinFormsObject("checkBox3").Checked =
    (DDT.CurrentDriver.Value("Greedy") = "Y")
    w1.WinFormsObject("button1").ClickButton
    Call w2.ClickItem("Fair Share")
    Log.PopLogFolder()
    End Sub

    7.Event Handle
    1)General Event handle:
    Testcomplete has a rich set of events for handling common scenarios:
    1.1) General Events
    Name                 Descrīption
    OnLogCloseNode     Occurs when a log folder is pop off the log.
    OnLogCreateNode     Occurs when a new log folder is appended on the log.
    OnLogError         Occurs when an error message is posted to the log.(Most commonly used.But if you set LogParams.Locked

    = true, TC will not post a message at all to the log)
    OnLogEvent         Occurs when an event message is posted to the log.
    OnLogFile         Occurs when a file is posted to the log.
    OnLogLink         Occurs when a file reference (link) is posted to the log.
    OnLogMessage        Occurs when a information message is posted to the log.
    OnLogPicture         Occurs when a picture (image) is posted to the log.
    OnLogWarning         Occurs when a warning message is posted to the log.
    OnOverlappingWindow    Occurs when a overlapping window appears.
    OnTimeout        Occurs when a timeout expires in a project or project suite.
    OnUnexpectedWindow    Occurs when an unexpected window appears.
    OnValidate         Occurs when the objects Validate method is called.

    1.2)HTTP LoadTesting Events:
    Name                     Descrīption
    OnLoadTestingRequest        Occurs just before TestComplete send an HTTP request to the tested Web Server.
    OnLoadTestingResponse        Occurs just after TestComplete receives a response to an HTTP request.

    1.3)Manual Testing Events
    Name                 Descrīption
    OnBeforeStep         Occurs before the next step is display to the user
    OnGetNextStep         Occurs when TestComplete get the information about what the next step is to be executed
    OnResume         Occurs when a manual test is about to be resumed.
    OnStepFailed         Occurs when a user click the Fail button in the Step Dialog
    OnStepSuccess         Occurs when a user click the Success button in the Step Dialog
    OnSuspend         Occurs when the manual test is suspended
    OnTestStep         Occurs when the user stops the manual test.

    1.4)NetworkSuite Events
    Name                     Desciption
    OnNetJobStateChange        Occurs when a job's state changes.
    OnNetSuiteStateChange        Occurs when the Network Suite's state changes.
    OnNetTaskStateChange        Occurs when a task's state changes.
    OnNetVarChange         Occurs when the value of a Network Suite variable changes.

    1.5)Test Engine Events
    Name                     Descrīption
    OnStartTest             Occurs when a TestComplete test starts.
    OnStopTest             Occurs when a test is over.

    1.6)Web Testing Events
    Name                     Descrīption
    OnWebBeforeNavgate        Occurs before Internet Explorer navigates to the specified Web Page
    OnWebDownloadStarted        Occurs when the download of a web is starting.
    OnWebDownloadComplete    Occurs when the downloading of a web page is completed, failed or halted.
    OnWebPageDownloaded        Occurs after Internet Explorer loads the specified page (or frame)
    OnWebQuite             Occurs before Internet Explorer closes.

    2)Unexpected Windows
    Note:TC has default handling for an unexpected window if "Ignore unexpected window" is not checked.

    7. Working with Database
    1)There are two methods: ADO(ActiveX Data Object) and BDE(Borland Database Engine)
    The table below shows the available methods:
    Microsoft(2)                 Borland(2)
    CreateCommand             CreateADOCommand
    CreateConnection          CreateADOConnection
                              CreateADODataSet
                              CreateADOQuery
                              CreateADOStoredProc
                              CreateADOTable

    2)Note:These methods below are specialized extensions of CreateADOCommand: CreateADODataSet, CreateADOQuery,

    CreateADOStoredProc, CreateADOTable.
    Caution: TestComplete can not use the .NET-only connection string (for example the SqlConnection for SQL Server 2005).

    3)The steps to query a database using ADO:
    3.1) Create an Connection to the database.
    3.2) Open the Connection.
    3.3) Create an Query Command.
    3.4) Execute the Query Command.
    3.5) Do something with the returned RecordSet.
    3.6) Close the Connection.
    Example:
    [VBscrīpt]
    Sub Main
    ' Create a new Connection object
    Set AConnection = ADO.CreateConnection
    ' Note that you can also create an ADO connection using the following code:
    ' Set AConnection = CreateObject("ADODB.Connection")
    ' Specify the connection string
    AConnection.ConnectionString = _
    "Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _
    "Persist Security Info=False;" & _
    "Initial Catalog=AdventureWorks;Data Source=.\SQLExpress"
    ' Activate the connection
    AConnection.Open
    ' Create a new Command object
    Set Cmd = ADO.CreateCommand
    ' To create an ADO command you can also use the following code:
    ' Set Cmd = CreateObject("ADODB.Command")
    ' Specify the connection
    Cmd.ActiveConnection = AConnection
    ' Specify command type and text
    Cmd.CommandText = _
    "SELECT CustomerID, TerritoryID, AccountNumber, CustomerType," & _
    " rowguid, ModifiedDate FROM Sales.Customer WHERE (CustomerType = ?)"
    Cmd.CommandType = adCmdText
    ' Create a new parameter
    Set Prm = Cmd.CreateParameter("@CustType",DB.adVarChar, DB.adParamInput)
    ' Specify the parameter value
    Prm.Size= 1
    Prm.Value = "S"
    Cmd.Parameters.Append(Prm)
    ' Execute the command
    Set RecSet = Cmd.Execute
    ' Execute the command
    RecSet.MoveFirst
    While Not RecSet.EOF
    Log.Message(RecSet("CustomerID").Value & " has account " & _
    RecSet("AccountNumber").Value)
    RecSet.MoveNext
    WEnd
    AConnection.Close
    End Sub

    8. Suggetstion about Best Practices
    1) Record/Playback is a quick and easy way to get automated tests up and running but tend to be brittle leading to problems

    when the application changes, etc.
    2) Use the TestItems of the project as a framework for Test Cases.
    3) Separate Data from the Test Framework (see Data-Driven Testing).
    4) Use the code metrics of the Code Explorer to improve the quality of the scrīpt code.
    5) Use Name Mapping and Aliases whenever possible, it is worth the time to setup.
    6) Use reusable routines whenever possible.
    7) Keep routines short (less than a page of code).
    8) Use meaningful variable names (The default variable names of a recording are not very good variable names).

    Referrence:
    1. Made easy Testcomplete
    2. TestComplete 6
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-18 04:48 , Processed in 0.088680 second(s), 28 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表