gui testing for - ntut.edu.twwkchen/courses/ooad/files/ref_hw_a.pdf · scope gui testing tool for...

112
Object-Oriented Analysis and Design GUI Testing Tool for .NET HW#7 四電資四 95820310 陳怡靜 四電資四 95820322 胡朝翔

Upload: others

Post on 17-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

  • Object-Oriented Analysis and Design

    GUI Testing Tool for .NET

    HW#7

    四電資四 95820310 陳怡靜

    四電資四 95820322 胡朝翔

  • ~ 2 ~ 

    目 錄

    1  Requirement Document.........................................................................................4 

    1.1  Change History..............................................................................................4 1.2  A problem statement .....................................................................................6 1.3  System Context Diagram..............................................................................6 1.4  Summary of System Features ......................................................................6 1.5  Use Case Diagram .........................................................................................7 1.6  Use Cases........................................................................................................7 

    1.6.1  Manage Script ...................................................................................7 1.6.2  Play Script and Return Results .....................................................10 1.6.3  Load Script ......................................................................................12 1.6.4  Store Script ......................................................................................13 

    1.7  Non-functional Requirements and Constraints .......................................14 1.8  Glossary .......................................................................................................15 1.9  Software Environments ..............................................................................15 

    2  Domain Class Model ............................................................................................16 2.1  Domain Class Diagram Showing Only Concepts .....................................16 

    2.1.1  Classes Identified (*new) ................................................................16 2.1.2  Bad Classes (*new)..........................................................................17 2.1.3  Good Classes....................................................................................18 

    2.2  Add Associations .........................................................................................19 2.3  Add Attributes .............................................................................................20 

    3  Logical Architecture ............................................................................................21 4  Class Design ..........................................................................................................22 

    4.1  Use-Case Realizations with GRASP Patterns...........................................22 4.1.1  System Sequence Diagram .............................................................22 4.1.2  Operation Contract.........................................................................25 4.1.3  Operation Sequence Diagram ........................................................30 

    4.2  Design Class Model (domain class model after class design) (new) .......41 5  Implementation Class Model ..............................................................................42 

    5.1  Draw an implementation class diagram for your system (including associations, attributes and methods) (new) ......................................................42 5.2  Show the difference between implementation class model and design class model (new)..................................................................................................44 5.3  Calculate Line of Code (new).....................................................................49 

    6  Programming........................................................................................................50 6.1  Snapshots of system execution ...................................................................50 

  • ~ 3 ~ 

    6.2  Source Code Listing ....................................................................................50 6.2.1  Program.cs .......................................................................................50 6.2.2  FormView.cs ....................................................................................51 6.2.3  AddCheckValue.cs ..........................................................................57 6.2.4  AddComponent.cs ...........................................................................59 6.2.5  AddConfiguration.cs.......................................................................60 6.2.6  AddEvent.cs .....................................................................................62 6.2.7  AddMethod.cs..................................................................................63 6.2.8  AddName.cs .....................................................................................64 6.2.9  AddParameter.cs .............................................................................66 6.2.10  AddTestCaseName.cs......................................................................67 6.2.11  Component.cs ..................................................................................68 6.2.12  DoTestAction.cs ...............................................................................69 6.2.13  Event.cs ............................................................................................76 6.2.14  File.cs................................................................................................77 6.2.15  Method.cs .........................................................................................78 6.2.16  Item.cs ..............................................................................................80 6.2.17  ItemList.cs........................................................................................81 6.2.18  Script.cs............................................................................................83 6.2.19  PlayScriptAndReturnResultsHandler.cs ......................................87 6.2.20  ManageScriptHandler.cs ................................................................88 

    7  Unit Testing...........................................................................................................90 7.1  Snapshots of testing result ..........................................................................90 7.2  Unit Testing Code Listing ...........................................................................91 

    7.2.1  TestComponent.cs ...........................................................................91 7.2.2  TestDoTestAction.cs ........................................................................92 7.2.3  TestEvent.cs .....................................................................................92 7.2.4  TestFile.cs.........................................................................................94 7.2.5  TestItem.cs .......................................................................................95 7.2.6  TestItemList .....................................................................................97 7.2.7  TestManageScriptHandler.cs .........................................................99 7.2.8  TestMethod.cs ................................................................................104 7.2.9  TestPlayScriptAndReturnResultsHandler.cs .............................106 7.2.10  TestScript.cs ...................................................................................106 

  • ~ 4 ~ 

    1 Requirement Document

    1.1 Change History

    Revision Description Date Iteration I

    1 Problem statement. Mar 10, 2010

    2

    Problem Statement refinement. System Context Diagram. Summary of System Features. Use Case Diagram. Use Cases. Non-functional Requirements and Constraints. Glossary. Software Environments refinement.

    Mar 17, 2010

    3

    System Context Diagram refinement. Use Cases refinement. Non-functional Requirements and Constraints refinement. Glossary refinement. Domain Class Diagram. Add Associations. Add Attributes.

    Mar 31, 2010

    4

    System Context Diagram refinement. Use Cases refinement. Glossary refinement. Domain Class Diagram refinement. Logical Architecture. System Sequence Diagram. Operation Contract. Operation Sequence Diagram. Design Class Model.

    Apr 19, 2010

    5

    Problem Statement refinement. System Context Diagram refinement. Summary of System Features refinement. Use Case Diagram refinement. Use Cases refinement. Glossary refinement.

    May 12, 2010

  • ~ 5 ~ 

    Domain Class Model refinement. Logical Architecture refinement. Class Design refinement. Implementation Class Model. Programming. Unit Testing. Midterm review response list.

    Iteration II

    6

    Use Cases refinement. Classes Identified refinement. Bad Classes refinement. Operation Sequence Diagram refinement. Design Class Model refinement.

    May 26, 2010

    7

    Problem Statement refinement. Use Cases refinement. Glossary refinement. Domain Class Model refinement. Class Design refinement. Implementation Class Model refinement. Programming refinement. Unit Testing refinement.

    June 14, 2010

  • ~ 6 ~ 

    1.2 A problem statement

    本軟體主要是為了需要測試 .NET 開發程式的測試人員而設計,主要應用在 .NET 平台所開發的程式之上。

    近年來軟體開發廣泛地使用圖形使用者介面(Graphical User Interface),而在軟體開發過程中,需要不斷地進行單元測試工作,每寫一小段程式碼,即需編譯執行結果,檢查是否有 Bug,但是手動測試過程往往浪費很多時間。

    本軟體可以重複播放預先設置的腳本,因此可以大幅降低軟體測試所需

    花費的時間,就連只是熟悉元件功能卻不懂撰寫程式碼的人員,只要學會本

    軟體操作步驟,就算沒有測試經驗,也能夠輕易地加入軟體測試的工作。

    Test Script 主要以文字的方式呈現,使用者只需要經由選取元件功能,一步一步擬定測試的腳本,軟體將會執行腳本且依序產生動作,並與使用者

    所設定的預期結果進行比對,完成測試工作。

    1.3 System Context Diagram

    Figure 1-1 System Context Diagram

    1.4 Summary of System Features

    Feature ID Description FEA-01 編輯管理 Script FEA-02 執行 Script 並回傳 Test Results FEA-03 載入 Script FEA-04 儲存 Script

  • ~ 7 ~ 

    1.5 Use Case Diagram

    Figure 1-2 Use Case Diagram

    1.6 Use Cases

    1.6.1 Manage Script

    Scope GUI Testing Tool for .NET Level User-goal Primary Actor Tester

    Stakeholders and Interests

    - Tester: Wants to write a list of event procedure what some AUT should follow. And insert some assertions in appropriate position and input check value for some component.

    Preconditions

    1. Tester knows what kind of component that AUT has.

    2. Tester knows AUT component’s name.

    Success Guarantee - Tester can finish script what he think

    in mind.

  • ~ 8 ~ 

    Main Success Scenario

    1. Tester adds a new test case. 2. System asks Tester to assign the

    test case name. 3. Tester enters the test case name. 4. System adds the test case to script

    and presents. 5. Tester adds a new item. 6. System returns the component list

    and asks Tester to choose. 7. Tester selects the component. 8. System returns the event list and

    asks Tester to choose. 9. Tester selects the event. 10. System asks Tester to assign the

    component’s name. 11. Tester specifies which component

    in AUT should be connected in this item and enters the component’s name.

    12. System adds this item to item list. 13. System presents item list so far. 14. Tester repeats step 5 -13 until the

    test case has done. 15. Tester repeats step 1-14 until all

    test cases of script for AUT have done.

    Extensions

    5a. Tester wants to insert an assertion: 1. Tester inserts an assertion in

    some position. 2. System returns the component

    list and asks Tester to choose. 3. Tester selects the component. 4. System asks Tester to assign

    the component’s name. 5. Tester specifies which

    component in AUT should be connected in this item and enters the component’s name

    6. System returns the method list

  • ~ 9 ~ 

    and asks Tester to choose. 7. Tester selects the method and

    gives check value to this item. 8. Go to step 12.

    5b. Tester wants to modify some event components: 1. Tester chooses one event

    component. And modify something like event, name.

    2. System modifies this item. 3. Go to step 13.

    5c. Tester wants to modify some assertion component: 1. Tester chooses one assertion

    component. And modify check value or method.

    2. System modifies this item. 3. Go to step 13.

    5d. Tester wants to delete some item: 1. Tester chooses one item and

    deletes it. 2. System removes this item from

    script. 3. Go to step 13.

    5e. Tester wants to insert some event component: 1. Tester inserts an event in some

    position. 2. Go to step 6.

    9a. Tester selects a event that need parameter: 1. System asks Tester to assign a

    parameter. 2. Tester enters parameter. 3. Go to step 10.

    Special Requirements - None.

    Technology and Data Variations List

    6a. Those components should exist in .NET.

    8a. Those events should exist in .NET.

  • ~ 10 ~ 

    Frequency of Occurrence Often.

    Open Issues

    1. Is there more easily way to manage script?

    2. Does tester always know what kind of component, event, or method should be chosen?

    3. How to choose the more appropriate place to insert assertion?

    1.6.2 Play Script and Return Results

    Scope GUI Testing Tool for .NET Level User-goal Primary Actor Tester

    Stakeholders and Interests

    - Customer: Wants the script can be played clearly.

    - Tester: Wants the script can be executed quickly and exactly.

    Preconditions - At least exist one script file can be

    played. - System should be opened.

    Success Guarantee

    - All the events and assertions should be executed.

    - System can return the result back to Tester.

    Main Success Scenario

    1. Tester assigns the configuration like entering the AUT’s name and the AUT’s location.

    2. System sets the configuration. 3. Tester issued the play command. 4. System produces the test actions

    according to script. 5. System finds and runs the AUT

    according the configuration. 6. System runs the events and checks

    assertions in order on the AUT. 7. System returns the result.

    Extensions 5a. Invalid AUT:

  • ~ 11 ~ 

    1. System signals error to the Tester.

    2. Back to the step 1. 6a. Invalid component:

    1. System signals error to the Tester.

    2. System points out which component is invalid.

    3. Tester modified the component.

    4. Back to the step 3. 6b. Invalid event:

    1. System signals error to the Tester.

    2. System points out which event is invalid.

    3. Tester modified the event. 4. Back to the step 3.

    6c. Invalid assertion: 1. System signals error to the

    Tester. 2. System points out which

    assertion is invalid. 3. Tester modified the assertion. 4. Back to the step 3.

    Special Requirements - None Technology and Data Variations List

    - None

    Frequency of Occurrence Could be nearly continuous. Open Issues - Can the Tester interrupt the play?

  • ~ 12 ~ 

    1.6.3 Load Script

    Scope GUI Testing Tool for .NET Level Sub-function Primary Actor Tester

    Stakeholders and Interests- Tester: Wants System to transform

    the file to the script quickly.

    Preconditions

    - Tester should know the location of the file.

    - The format of the file should be correctly.

    Success Guarantee - All the events and assertions can be

    show on the view.

    Main Success Scenario (new)

    1. Tester issued the load command. 2. System asks Tester to enter file

    location. 3. Tester assigns the file location. 4. System opens the file. 5. System turns the file into the

    events and assertions which can be executed.

    6. System shows all the events and assertions in each test case on the view in order.

    Extensions

    4a. Invalid location: 1. System signals error to the

    Tester. 2. Tester gives System a correct

    location of file which has a correct format.

    5a. Invalid transform: 1. System signals error to the

    Tester. 2. System returns the error report.3. Back to step 6.

    Special Requirements - None Technology and Data Variations List

    4a. The format of file should be structurally.

    Frequency of Occurrence Often.

  • ~ 13 ~ 

    Open Issues

    1.6.4 Store Script

    Scope GUI Testing Tool for .NET Level Sub-function Primary Actor Tester

    Stakeholders and Interests- Tester: Wants System to record the

    script into file completely.

    Preconditions - At least exist one script file can be

    stored.

    Success Guarantee - All the events and assertions can be

    recorded completely.

    Main Success Scenario (new)

    1. Tester issued the store command. 2. System asks Tester to enter store

    location. 3. Tester assigns the store location. 4. System transforms the script into

    the specific format. 5. System stores the specific format

    as a file. 6. System returns the success report.

    Extensions

    4a. Invalid transform: 1. System signals error to the

    Tester. 2. System returns the error report.3. Back to step 4.

    5a. Store location isn’t exist: 1. System signals error to the

    tester. 2. System asks Tester whether to

    build new file folder. 3. System builds new file folder

    and stores. 3a. Tester doesn’t want to build

    new file folder. 1. Back to step 3.

    4. Back to step 6. Special Requirements - None

  • ~ 14 ~ 

    Technology and Data Variations List

    4a. The format of file should be structurally.

    Frequency of Occurrence - Often. Open Issues

    1.7 Non-functional Requirements and Constraints

    NFR ID Category Description

    NFR-01 Performance Script 每加入一個項目,System 就要立刻更新 Script

    NFR-02 Usability System 必須很容易地讓 User 操作編輯、執行與播放

    NFR-03 Reliability 檔案讀寫過程中,須確保資料轉換的正確性

    NFR-04 Performance 存讀檔需在短時間內完成

  • ~ 15 ~ 

    1.8 Glossary

    Item Definition or Description

    Test case 測試案例。包含 Events 及 Assertions,以一個 case 為單位,可進行播放。

    Event 元件所能發生的事件,就是使用者能對某物件操作什麼

    樣的事情,例如 Click,MouseEnter,MouseLeave…等

    AUT Application Under Test,即待測程式,是一個由 .NET 所開發的程式,當系統做播放動作時,AUT 將被開啟並且一步一步執行 Script

    Assertion

    驗證點,當 Tester 要在 Script 某個地方檢查當 AUT 播放執行至此的狀態時,就插入 Assertion,並且先給予一個預想狀態,則 AUT 播放時,就能回傳是否與預想狀態相同

    Check value

    為了能夠在中斷點檢查目前的狀態是否如預期所想,則

    在中斷點設定一個 Check Value,讓 AUT 跑 Script 的時候經過此中斷點,就可以檢查目前程式上的某個值是否

    與 Check Value 相同

    Component 這裡指 .NET 程式上面的元件名稱,系統主要測試 AUT的方式是以操作 Component 為主,例如 Button, Check Box,Text Box…等

    Configuration 程式組態,指定 AUT 的名稱及位置以及相關的資料,以供 System 開啟時能夠參考

    File 紀錄 Script 的檔案,具有結構性的格式,它也可以被系統讀取並且轉換為 Script,是一種儲存的方式

    1.9 Software Environments

    This project will be written in C# programming language.

  • ~ 16 ~ 

    2 Domain Class Model

    2.1 Domain Class Diagram Showing Only Concepts

    2.1.1 Classes Identified (*new)

    Tester Test Case Test Case Name

    Item System

    Component List

    Component Event List Event Component’s Name

    AUT Item List Script Assertion Position

    Method List Method Check Value

    Name Parameter

    Configuration AUT’s Name

    AUT’s Location

    Play Command

    Test Actions

    Result Error *Load Command

    *File Location

    File

    View Location Format Error Report

    Store Location

    Store Command

    Success Report

    File Folder

    以上為使用 Identify noun phrases 在 Use Cases 所找出的單詞

  • ~ 17 ~ 

    2.1.2 Bad Classes (*new)

    Attributes Vague Operation Roles Implementation Construction

    Test Case Name Position Play Command

    System Test Case

    Component Name *Load Command

    View Assertion

    Event Error *File Location

    Format

    Component’s Name

    Location Error Report Configuration

    Method Store Result Check Value Command

    Parameter Success Report

    AUT’s Name

    AUT’s Location File Folder

    Store Location

    以上將不好的 Classes 歸類成五大類

    Attributes:列為屬性 Vague:定義模糊不清 Operation:操作步驟中的ㄧ部份 Roles:角色介面 Implementation Construction:實作產生的結構

  • ~ 18 ~ 

    2.1.3 Good Classes

    Tester Item Component List

    Event List AUT

    *Item List Script Method List Test Actions File

    剩餘的 Good Classes

    Figure 2-1 Domain Class Diagram Only Concepts

  • ~ 19 ~ 

    2.2 Add Associations

    One Tester manages several Scripts. One Script produces the Test Actions. The Test Actions run at one AUT. One Script sends result to Tester. One Script can be stored as one File. One Script is composed of several Item Lists. One Item List is composed of several Items. Script owns Component List. Script owns Event List. Script owns Method List.

    Figure 2-2 Domain Class Diagram with Associations

  • ~ 20 ~ 

    2.3 Add Attributes

    Figure 2-3 Domain Class Diagram with Attributes

  • ~ 21 ~ 

    3 Logical Architecture

    Figure 3-1 Logical Architecture in UML package diagram

  • ~ 22 ~ 

    4 Class Design

    4.1 Use-Case Realizations with GRASP Patterns

    4.1.1 System Sequence Diagram

    Figure 4-1 System Sequence Diagram of use case: Manage Script

  • ~ 23 ~ 

    Figure 4-2 System Sequence Diagram of use case: Manage Script (Extension)

    Figure 4-3 System Sequence Diagram of use case: Play Script and Return Result

  • ~ 24 ~ 

    (new) Figure 4-4 System Sequence Diagram of use case: Load Script

    (new) Figure 4-5 System Sequence Diagram of use case: Store Script

  • ~ 25 ~ 

    4.1.2 Operation Contract

    Contract ID Operation Name CO-01 addNewTestCase

    CO-02 addNewItem

    CO-03 selectEventComponent

    CO-04 selectEvent

    CO-05 assignEventComponent

    CO-06 insertNewAssertionItem

    CO-07 selectAssertionComponent

    CO-08 assignAssertionComponent

    CO-09 selectMethod

    CO-10 assignCheckValue

    CO-11 assignConfiguration

    CO-12 issuePlayCommand

    (new) CO-13 issueLoadCommand

    (new) CO-14 assignFileLocation

    (new) CO-15 issueStoreCommand

    (new) CO-16 assignStoreLocation

    4.1.2.1 addNewTestCase

    Operation addNewTestCase(tcName: string) Cross References Use Case: Manage Script Preconditions - Tool was opened.

    Postconditions - An Item List instance il was created

    (instance creation).

    4.1.2.2 addNewItem

    Operation addNewItem(tcNumber: int) Cross References Use Case: Manage Script Preconditions - An Item List instance il was created.

    Postconditions - An Item instance i was created (instance

    creation). - The component list was returned.

    4.1.2.3 selectEventComponent

  • ~ 26 ~ 

    Operation selectEventComponent(c: string, tcNumber: int)

    Cross References Use Case: Manage Script

    Preconditions - An Item List instance il was created. - An Item instance i was created.

    Postconditions

    - i.component became c (attribute modification).

    - The event list which related to c was returned.

    4.1.2.4 selectEvent

    Operation selectEvent(e: string, tcNumber: int) Cross References Use Case: Manage Script

    Preconditions - An Item List instance il was created. - An Item instance i was created. - i.component was assigned.

    Postconditions - i.event became e (attribute modification). - Selected Event e was associated with the

    Component (association formed).

    4.1.2.5 assignEventComponent

    Operation assignEventComponent(cName: string, nNumber: int, tcNumber: int)

    Cross References Use Case: Manage Script

    Preconditions

    - Tester needs to know the component name of AUT

    - An Item List instance il was created. - An Item instance i was created. - i.component was assigned. - i.event was assigned.

    Postconditions - i.componentName became cName (attribute

    modification). - The item was added into il.

    4.1.2.6 insertNewAssertionItem

    Operation insertNewAssertionItem (tcNumber: int) Cross References Use Case: Manage Script (Extension)

  • ~ 27 ~ 

    Preconditions - Tool was opened. - An Item List instance il was created. - At least one event item exist.

    Postconditions - An Item instance i was created (instance

    creation). - The component list was returned.

    4.1.2.7 selectAssertionComponent

    Operation selectAssertionComponent(c: string, tcNumber: int)

    Cross References Use Case: Manage Script (Extension)

    Preconditions - An Item List instance il was created. - An Item instance i was created.

    Postconditions - i.component became c (attribute

    modification).

    4.1.2.8 assignAssertionComponent

    Operation assignAssertionComponent(cName: string, tcNumber: int)

    Cross References Use Case: Manage Script (Extension)

    Preconditions

    - Tester needs to know the component name of AUT

    - An Item List instance il was created. - An Item instance i was created. - i.component was assigned.

    Postconditions

    - i.componentName became cName (attribute modification).

    - The method list which related to i.component was returned.

    4.1.2.9 selectMethod

    Operation selectMethod(m: string, tcNumber: int) Cross References Use Case: Manage Script (Extension)

    Preconditions

    - An Item List instance il was created. - An Item instance i was created. - i.component was assigned. - i.componentName was assigned.

  • ~ 28 ~ 

    Postconditions - i.method became m (attribute modification).- Selected Method m was associated with the

    Component (association formed).

    4.1.2.10 assignCheckValue

    Operation assignCheckValue(v: string, nNumber: int, tcNumber: int)

    Cross References Use Case: Manage Script (Extension)

    Preconditions

    - Tester needs to know the ideal status in AUT the value is.

    - An Item List instance il was created. - An Item instance i was created. - i.component was assigned. - i.componentName was assigned. - i.method was assigned.

    Postconditions - i.checkValue became v (attribute

    modification). - The item was inserted into il.

    4.1.2.11 assignConfiguration

    Operation assignConfiguration (name: string, location: string)

    Cross References Use Case: Play Script and Return result

    Preconditions - Tester should know AUT’s name and AUT’s

    location. - Tool was opened.

    Postconditions

    - Script s.AUTName became name (attribute modification).

    - Script s.AUTLocation became location (attribute modification).

    4.1.2.12 issuePlayCommand

    Operation issuePlayCommand() Cross References Use Case: Play Script and Return result Preconditions - Tool was opened.

    Postconditions - Manage Script was Enable. Until System

    return result or error message.

  • ~ 29 ~ 

    4.1.2.13 issueLoadCommand (new)

    Operation issueLoadCommand() Cross References Use Case: Load Script Preconditions - Tool was opened. Postconditions - System issued requirement.

    4.1.2.14 assignFileLocation (new)

    Operation assignFileLocation() Cross References Use Case: Load Script Preconditions - Tester needs to know the location of file.

    Postconditions

    - Each Item List instance il was created (instance creation).

    - Each Item instance i was created (instance creation).

    - Each i.component was assigned. - Each i.event was assigned. - Each i.method was assigned. - Each i.componentName was assigned. - Each i.checkValue was assigned. - Each i.parameter was assigned. - Each i was added into il in order according

    the Test Case.

    4.1.2.15 issueStoreCommand (new)

    Operation issueStoreCommand() Cross References Use Case: Store Script Preconditions - The Script instance s was created. Postconditions - System issued requirement.

    4.1.2.16 assignStoreLocation (new)

    Operation assignStoreLocation(sl: string) Cross References Use Case: Store Script Preconditions - Tester needs to enter a correct location.

    Postconditions - File was created. - The success message was returned.

  • ~ 30 ~ 

    4.1.3 Operation Sequence Diagram

    4.1.3.1 addNewTestCase

    Figure 4-6 Sequence Diagram: addNewTestCase

  • ~ 31 ~ 

    4.1.3.2 addNewItem

    Figure 4-7 Sequence Diagram: addNewItem

  • ~ 32 ~ 

    4.1.3.3 selectEventComponent

    Figure 4-8 Sequence Diagram: selectEventComponent

    4.1.3.4 selectEvent

    Figure 4-9 Sequence Diagram: selectEvent

  • ~ 33 ~ 

    4.1.3.5 assignEventComponent

    Figure 4-10 Sequence Diagram: assignEventComponent

    4.1.3.6 insertNewAssertionItem

    Figure 4-11 Sequence Diagram: insertNewAssertionItem

  • ~ 34 ~ 

    4.1.3.7 selectAssertionComponent

    Figure 4-12 Sequence Diagram: selectAssertionComponent

    4.1.3.8 assignAssertionComponent

    Figure 4-13 Sequence Diagram: assignAssertionComponent

  • ~ 35 ~ 

    4.1.3.9 selectMethod

    Figure 4-14 Sequence Diagram: selectMethod

    4.1.3.10 assignCheckValue

    Figure 4-15 Sequence Diagram: assignCheckValue

  • ~ 36 ~ 

    4.1.3.11 assignConfiguration

    Figure 4-16 Sequence Diagram: assignConfiguration

  • ~ 37 ~ 

    4.1.3.12 issuePlayCommand

    Figure 4-17 Sequence Diagram: issuePlayCommand

  • ~ 38 ~ 

    4.1.3.13 issueLoadCommand (new)

    Figure 4-18 Sequence Diagram: issueLoadCommand

  • ~ 39 ~ 

    4.1.3.14 assignFileLocation (new)

    Figure 4-19 Sequence Diagram: assignFileLocation

  • ~ 40 ~ 

    4.1.3.15 issueStoreCommand (new)

    Figure 4-20 Sequence Diagram: issueStoreCommand

    4.1.3.16 assignStoreLocation (new)

    Figure 4-21 Sequence Diagram: assignStoreLocation

  • ~ 41 ~ 

    4.2 Design Class Model (domain class model after class design) (new)

    Figure 4-15 Design Class Diagram

  • ~ 42 ~ 

    5 Implementation Class Model

    5.1 Draw an implementation class diagram for your system (including associations, attributes and methods) (new)

  • ~ 43 ~ 

  • ~ 44 ~ 

    5.2 Show the difference between implementation class model and design class model (new)

    Class Method Design Imp. Program

    (added in imp. phase) Main() No Yes

    issueLoadCommand() Yes No assignFileLocation() Yes No issueStoreCommand() Yes No ScriptTreeViewUpdate() No Yes CheckIsButtonEnable() No Yes DecideCurrentTestCaseNode() No Yes DecideCurrentSelectedNode() No Yes DecideSelectedNodeIndex() No Yes eventToolStripMenuItem_Click() No Yes testCaseToolStripMenuItem_Click() No Yes ScriptInsertTestCase() No Yes assertionToolStripMenuItem_Click() No Yes ScriptInsertAssertion() No Yes ScriptAddEvent() No Yes ScriptTreeView_MouseDoubleClick() No Yes ScriptTreeView_KeyUp() No Yes AddComponentToolStripMenuItem_Click() No Yes PlayToolStripMenuItem_Click() No Yes SetToolStripMenuItem_Click() No Yes expandAllToolStripMenuItem_Click() No Yes ErrorUpdate() No Yes CorrectUpdate() No Yes TestCaseUpdate() No Yes clearBackColor() No Yes TreeviewAddNode() No Yes SaveToolStripMenuItem_Click() No Yes LoadToolStripMenuItem_Click() No Yes

    FormView

    buildScriptModel() No Yes button1_Click () No Yes AddCheckValue

    (added in imp. phase) button2_Click() No Yes button1_Click() No Yes AddComponent

    (added in imp. phase) button2_Click() No Yes

  • ~ 45 ~ 

    button1_Click() No Yes button2_Click() No Yes

    AddConfiguration (added in imp. phase)

    button3_Click() No Yes button1_Click() No Yes AddEvent

    (added in imp. phase) button2_Click() No Yes button1_Click() No Yes AddMethod

    (added in imp. phase) button2_Click() No Yes OKButton_Click() No Yes AddName

    (added in imp. phase) CancelButton_Click() No Yes OKButton_Click() No Yes AddParameter

    (added in imp. phase) CancelButton_Click() No Yes OKButton_Click() No Yes AddTestCaseName

    (added in imp. phase) CancelButton_Click() No Yes Component getComponentList() Yes Yes

    setConfig() Yes No LuanchAUT() Yes Yes CloseAUT() Yes Yes produceAction() Yes Yes EventAction() No Yes DoEvent() No Yes EventMouseStartDragging() No Yes EventMouseStopDragging() No Yes EventKeyBoardReleaseModifierKeys() No Yes EventKeyboardPressModifierKeys() No Yes EventKeyboardKeyPress() No Yes EventMouseClick() No Yes EventMouseMove() No Yes EventMouseDoubleClick() No Yes EventMouseClick() No Yes MethodAction() No Yes DoAssert() No Yes AssertIsTopParent() No Yes AssertEnabled() No Yes AssertExists() No Yes AssertHasFocus() No Yes addDictionary() No Yes

    TestAction

    PredicateModifierKey() No Yes Event getEventList() Yes Yes

  • ~ 46 ~ 

    saveFile() Yes Yes buildXmlDocument() Yes Yes TestCaseToXmlNode() No Yes itemToXmlNode() No Yes

    File

    itemAttributeToXmlNode() No Yes Method getMethodList() Yes Yes

    setComponent() Yes Yes

    getComponent() Yes Yes setEvent() Yes Yes setComponentName() Yes Yes setMethod() Yes Yes setCheckValue() Yes Yes

    Item

    setParameter() Yes Yes addNewItem() Yes Yes insertNewAssertionItem() Yes Yes selectEventComponent() Yes Yes selectAssertionComponent() Yes Yes assignParameter() No Yes selectEvent() Yes Yes selectMethod() Yes Yes assignEventComponent() Yes Yes assignAssertionComponent() Yes Yes assignCheckValue() Yes Yes modifyNodeName() No Yes modifyNodeEvent() No Yes modifyEventParameter() No Yes modifyNodeMethod() No Yes modifyNodeCheckValue() No Yes deleteNode() No Yes

    ItemList

    LoadItemList() Yes Yes

  • ~ 47 ~ 

    TestCaseNotifyObserver() No Yes CorrectNotifyObserver() No Yes ErrorNotifyObserver() No Yes clearScript() No Yes addNewTestCase() Yes Yes addNewItem() Yes Yes insertNewAssertionItem() Yes Yes selectEventComponent() Yes Yes selectAssertionComponent() Yes Yes ConstructEventList() No Yes ConstructMethodList() No Yes selectEvent() Yes Yes selectMethod() Yes Yes assignEventComponent() Yes Yes assignCheckValue() Yes Yes assignAssertionComponent() Yes Yes modifyNodeName() No Yes modifyNodeEvent() No Yes modifyNodeMethod() No Yes modifyNodeCheckValue() No Yes deleteNode() No Yes deleteTestCaseNode() No Yes assignConfiguration() Yes Yes issuePlayCommand() Yes Yes LoadFile() Yes Yes assignStoreLocation() Yes Yes assignParameter() No Yes

    Script

    modifyEventParameter() No Yes

  • ~ 48 ~ 

    clearScript() No Yes addNewTestCase() Yes Yes addNewItem() Yes Yes selectEventComponent() Yes Yes selectAssertionComponent() Yes Yes selectEvent() Yes Yes selectMethod() Yes Yes assignEventComponent() Yes Yes assignAssertionComponent() Yes Yes assignCheckValue() Yes Yes modifyNodeName() No Yes ConstructEventList() No Yes ConstructMethodList() No Yes modifyNodeEvent() No Yes modifyNodeMethod() No Yes modifyNodeCheckValue() No Yes deleteNode() No Yes deleteTestCaseNode() No Yes assignParameter() No Yes modifyEventParameter() No Yes LoadFile() Yes Yes assignStoreLocation() Yes Yes

    ManageScriptHandler

    insertNewAssertionItem() Yes Yes TestCaseNotifyObserver() No Yes CorrectNotifyObserver() No Yes ErrorNotifyObserver() No Yes TestCaseUpdate() No Yes CorrectUpdate() No Yes ErrorUpdate() No Yes assignConfiguration() Yes Yes

    PlayScriptAndReturn ResultsHandler

    issuePlayCommand() Yes Yes

    Table 5.2.1: Comparison with design and implementation class

  • ~ 49 ~ 

    Number of added Number of removed Number of modified Class 9 0 7

    Method 103 4 10

    Table 5.2.2: Summary of implementation class/method changed

    5.3 Calculate Line of Code (new)

    No Class Name Number of Methods Line of Code in Class (without comment) 1 Program 1 21 2 FormView 25 535 3 AddCheckValue 2 107 4 AddComponent 2 111 5 AddConfiguration 3 170 6 AddEvent 2 98 7 AddMethod 2 98 8 AddName 2 109 9 AddParameter 2 108 10 AddTestCaseName 2 109 11 Component 0 38 12 TestAction 22 622 13 Event 0 86 14 File 5 84 15 Method 0 97 16 Item 0 97 17 ItemList 17 155 18 Script 28 398 19 ManageScriptHandler 23 163

    20 PlayScriptAndReturn ResultsHandler

    8 85

    SUM 146 3291

    Table 5.3.1: Line of Code of classes

  • ~ 50 ~ 

    6 Programming

    6.1 Snapshots of system execution

    6.2 Source Code Listing

    6.2.1 Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace GUITestTool { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormView()); } } }

  • ~ 51 ~ 

    6.2.2 FormView.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Web; using System.Windows.Forms; using System.Xml; namespace GUITestTool { public partial class FormView : Form { private XmlDocument doc; private ManageScriptHandler MSHandler; private PlayScriptAndReturnResultsHandler PSHandler; private AddComponent AC; private AddEvent AE; private AddMethod AM; private AddName AN; private AddParameter AP; private AddConfiguration ACf; private AddCheckValue ACV; private AddTestCaseName AT; private List FComponentElements; private List FEventElements; private List FMethodElements; private Item currentItem; private TreeNode root; private TreeNode SelectedNode; private TreeNode CurrentTestCaseNode; public FormView() { MSHandler = new ManageScriptHandler(); PSHandler = new PlayScriptAndReturnResultsHandler(MSHandler.Property_script); InitializeComponent(); FComponentElements = new List(); root = new TreeNode(); root.Name = "ROOT"; root.Text = "ROOT"; ScriptTreeView.Nodes.Add(root); PSHandler.ErrorNotify += ErrorUpdate; PSHandler.CorrectNotify += CorrectUpdate; PSHandler.TestCaseNotify += TestCaseUpdate; ScriptTreeView.AfterSelect += new TreeViewEventHandler(ScriptTreeViewUpdate); PlayToolStripMenuItem.Enabled = false; closeAllToolStripMenuItem.Enabled = false; } private void ScriptTreeViewUpdate(Object sender, EventArgs e) { CheckIsButtonEnable(); } private void CheckIsButtonEnable() { int a = ScriptTreeView.SelectedNode.Level; if (ScriptTreeView.SelectedNode.Level == 0 || ScriptTreeView.SelectedNode.Level == 1) { if (PSHandler.Property_script.Property_AUTLocation != "") PlayToolStripMenuItem.Enabled = true; } else PlayToolStripMenuItem.Enabled = false; } private TreeNode DecideCurrentTestCaseNode(TreeNode node) { if (node.Level == 1) return node; else return DecideCurrentTestCaseNode(node.Parent); } private TreeNode DecideCurrentSelectedNode(TreeNode node) { if (node.Level == 1) { return node;

  • ~ 52 ~ 

    } else if (node.Level == 2) { return node; } else if (node.Level == 3) { return DecideCurrentSelectedNode(node.Parent); } else // (node.Level == 4) { return DecideCurrentSelectedNode(node.Parent.Parent); } } private int DecideSelectedNodeIndex() { if (ScriptTreeView.SelectedNode.Level == 1) { if (ScriptTreeView.SelectedNode.GetNodeCount(false) == 0) return -1; else return ScriptTreeView.SelectedNode.LastNode.Index; } else //level ==2 return ScriptTreeView.SelectedNode.Index; } public void eventToolStripMenuItem_Click(object sender, EventArgs e) { CurrentTestCaseNode = DecideCurrentTestCaseNode(ScriptTreeView.SelectedNode); ScriptTreeView.SelectedNode = DecideCurrentSelectedNode(ScriptTreeView.SelectedNode); int NodeNumber = DecideSelectedNodeIndex(); FComponentElements = MSHandler.addNewItem(CurrentTestCaseNode.Index); AC = new AddComponent(FComponentElements); AC.ShowDialog(); if (AC.Property_index != -1) { FEventElements = MSHandler.selectEventComponent(FComponentElements[AC.Property_index], CurrentTestCaseNode.Index); AE = new AddEvent(FEventElements); AE.ShowDialog(); if (AE.Property_index != -1 && (FEventElements[AE.Property_index] == "KeyPress" || FEventElements[AE.Property_index] == "PressModifierKeys" || FEventElements[AE.Property_index] == "ReleaseModifierKeys") || FEventElements[AE.Property_index] == "Click(Point)" || FEventElements[AE.Property_index] == "StartDragging(Point)" || FEventElements[AE.Property_index] == "StopDragging(dX dY)") { AP = new AddParameter(); AP.ShowDialog(); if (AP.Property_Parameter != "") { MSHandler.assignParameter(AP.Property_Parameter, CurrentTestCaseNode.Index); } } if (AE.Property_index != -1) { MSHandler.selectEvent(FEventElements[AE.Property_index], CurrentTestCaseNode.Index); AN = new AddName(); AN.ShowDialog(); if (AN.Property_IdName != "") { currentItem = MSHandler.assignEventComponent(AN.Property_IdName, NodeNumber, CurrentTestCaseNode.Index); ScriptAddEvent(); ScriptTreeView.ExpandAll(); } } } } private void testCaseToolStripMenuItem_Click(object sender, EventArgs e) { AT = new AddTestCaseName(); AT.ShowDialog(); if (AT.Property_TestCaseName != "") { MSHandler.addNewTestCase(AT.Property_TestCaseName); ScriptInsertTestCase(AT.Property_TestCaseName); } }

  • ~ 53 ~ 

    private void ScriptInsertTestCase(string TestCaseName) { TreeNode TestCaseNode = new TreeNode(); TestCaseNode.Name = "TestCase"; TestCaseNode.Text = "TestCase: " + TestCaseName; TreeviewAddNode(root, TestCaseNode); ScriptTreeView.ExpandAll(); ScriptTreeView.SelectedNode = TestCaseNode; } private void assertionToolStripMenuItem_Click(object sender, EventArgs e) { CurrentTestCaseNode = DecideCurrentTestCaseNode(ScriptTreeView.SelectedNode); ScriptTreeView.SelectedNode = DecideCurrentSelectedNode(ScriptTreeView.SelectedNode); int NodeNumber = ScriptTreeView.SelectedNode.Index; FComponentElements = MSHandler.insertNewAssertionItem(CurrentTestCaseNode.Index); AC = new AddComponent(FComponentElements); AC.ShowDialog(); if (AC.Property_index != -1) { MSHandler.selectAssertionComponent(FComponentElements[AC.Property_index], CurrentTestCaseNode.Index); AN = new AddName(); AN.ShowDialog(); if (AN.Property_IdName != "") { FMethodElements = MSHandler.assignAssertionComponent(AN.Property_IdName, CurrentTestCaseNode.Index); AM = new AddMethod(FMethodElements); AM.ShowDialog(); if (AM.Property_index != -1) { MSHandler.selectMethod(FMethodElements[AM.Property_index], CurrentTestCaseNode.Index); ACV = new AddCheckValue(); ACV.ShowDialog(); if (ACV.Property_CheckValue != "") { currentItem = MSHandler.assignCheckValue(ACV.Property_CheckValue, NodeNumber, CurrentTestCaseNode.Index); ScriptInsertAssertion(); ScriptTreeView.ExpandAll(); } } } } } public void ScriptInsertAssertion() { TreeNode ComponentNode = new TreeNode(); ComponentNode.Name = "AssertComponent"; ComponentNode.Text = "AssertComponent: " + currentItem.Property_Component; TreeviewAddNode(ScriptTreeView.SelectedNode, ComponentNode); TreeNode MethodNode = new TreeNode(); MethodNode.Name = "Method"; MethodNode.Text = "Method: " + currentItem.Property_Method; ComponentNode.Nodes.Add(MethodNode); TreeNode NameNode = new TreeNode(); NameNode.Name = "Name"; NameNode.Text = "Name: " + currentItem.Property_ComponentName; ComponentNode.Nodes.Add(NameNode); TreeNode CheckValueNode = new TreeNode(); CheckValueNode.Name = "CheckValue"; CheckValueNode.Text = "CheckValue: " + currentItem.Property_CheckValue; ComponentNode.Nodes.Add(CheckValueNode); ScriptTreeView.SelectedNode = ComponentNode; CheckIsButtonEnable(); } public void ScriptAddEvent() { TreeNode ComponentNode = new TreeNode(); ComponentNode.Name = "EventComponent"; ComponentNode.Text = "EventComponent: " + currentItem.Property_Component; TreeviewAddNode(ScriptTreeView.SelectedNode, ComponentNode); TreeNode EventNode = new TreeNode(); EventNode.Name = "Event"; EventNode.Text = "Event: " + currentItem.Property_Event; ComponentNode.Nodes.Add(EventNode); if (currentItem.Property_Parameter != "")

  • ~ 54 ~ 

    { TreeNode ParameterNode = new TreeNode(); ParameterNode.Name = "Parameter"; ParameterNode.Text = "Parameter: " + currentItem.Property_Parameter; EventNode.Nodes.Add(ParameterNode); } TreeNode NameNode = new TreeNode(); NameNode.Name = "Name"; NameNode.Text = "Name: " + currentItem.Property_ComponentName; ComponentNode.Nodes.Add(NameNode); ScriptTreeView.SelectedNode = ComponentNode; CheckIsButtonEnable(); } public void ScriptTreeView_MouseDoubleClick(object sender, MouseEventArgs e) { if(ScriptTreeView.SelectedNode.Level != 0) CurrentTestCaseNode = DecideCurrentTestCaseNode(ScriptTreeView.SelectedNode); SelectedNode = ScriptTreeView.GetNodeAt(e.X, e.Y); if (SelectedNode.Text.StartsWith("Name: ")) { AN = new AddName(); AN.ShowDialog(); if (AN.Property_IdName != "") { int parentNodeNumber = SelectedNode.Parent.Index; MSHandler.modifyNodeName(AN.Property_IdName, parentNodeNumber, CurrentTestCaseNode.Index); SelectedNode.Text = "Name: " + AN.Property_IdName; } } else if (SelectedNode.Text.StartsWith("Event: ")) { FEventElements = MSHandler.ConstructEventList(SelectedNode.Parent.Text.Substring("EventComponent: ".Length, SelectedNode.Parent.Text.Length - "EventComponent: ".Length)); AE = new AddEvent(FEventElements); AE.ShowDialog(); int parentNodeNumber = SelectedNode.Parent.Index; if (AE.Property_index != -1) { MSHandler.modifyNodeEvent(FEventElements[AE.Property_index], parentNodeNumber, CurrentTestCaseNode.Index); TreeNode EventNode = new TreeNode(); EventNode.Name = "Event"; EventNode.Text = "Event: " + FEventElements[AE.Property_index]; ScriptTreeView.Nodes[0].Nodes[CurrentTestCaseNode.Index].Nodes[SelectedNode.Parent.Index].Nodes.Insert(SelectedNode.Index, EventNode); ScriptTreeView.Nodes.Remove(ScriptTreeView.SelectedNode); ScriptTreeView.SelectedNode = EventNode; if (FEventElements[AE.Property_index] == "KeyPress" || FEventElements[AE.Property_index] == "PressModifierKeys" || FEventElements[AE.Property_index] == "ReleaseModifierKeys" || FEventElements[AE.Property_index] == "Click(Point)" || FEventElements[AE.Property_index] == "StartDragging(Point)" || FEventElements[AE.Property_index] == "StopDragging(dX dY)") { AP = new AddParameter(); AP.ShowDialog(); if (AP.Property_Parameter != "") { MSHandler.modifyEventParameter(AP.Property_Parameter, parentNodeNumber, CurrentTestCaseNode.Index); TreeNode ParameterNode = new TreeNode(); ParameterNode.Name = "Parameter"; ParameterNode.Text = "Parameter: " + AP.Property_Parameter; EventNode.Nodes.Add(ParameterNode); } } } } else if (SelectedNode.Text.StartsWith("Parameter: ")) { AP = new AddParameter(); AP.ShowDialog(); if (AP.Property_Parameter != "") { int parentNodeNumber = SelectedNode.Parent.Parent.Index; MSHandler.modifyEventParameter(AP.Property_Parameter, parentNodeNumber, CurrentTestCaseNode.Index); SelectedNode.Text = "Parameter: " + AP.Property_Parameter; } }

  • ~ 55 ~ 

    else if (SelectedNode.Text.StartsWith("Method: ")) { FMethodElements = MSHandler.ConstructMethodList(SelectedNode.Parent.Text.Substring("AssertComponent: ".Length, SelectedNode.Parent.Text.Length - "AssertComponent: ".Length)); AM = new AddMethod(FMethodElements); AM.ShowDialog(); if (AM.Property_index != -1) { int parentNodeNumber = SelectedNode.Parent.Index; MSHandler.modifyNodeMethod(FMethodElements[AM.Property_index], parentNodeNumber, CurrentTestCaseNode.Index); SelectedNode.Text = "Method: " + FMethodElements[AM.Property_index]; } } else if (SelectedNode.Text.StartsWith("CheckValue: ")) { ACV = new AddCheckValue(); ACV.ShowDialog(); if (ACV.Property_CheckValue != "") { int parentNodeNumber = SelectedNode.Parent.Index; MSHandler.modifyNodeCheckValue(ACV.Property_CheckValue, parentNodeNumber, CurrentTestCaseNode.Index); SelectedNode.Text = "CheckValue: " + ACV.Property_CheckValue; } } } public void ScriptTreeView_KeyUp(object sender, KeyEventArgs e) { if (ScriptTreeView.SelectedNode.Level != 0) CurrentTestCaseNode = DecideCurrentTestCaseNode(ScriptTreeView.SelectedNode); if ((ScriptTreeView.SelectedNode.Name == "EventComponent" || ScriptTreeView.SelectedNode.Name == "AssertComponent") && e.KeyCode == Keys.Delete) { int NodeNumber = ScriptTreeView.SelectedNode.Index; MSHandler.deleteNode(NodeNumber,CurrentTestCaseNode.Index); ScriptTreeView.Nodes.Remove(ScriptTreeView.SelectedNode); } else if (ScriptTreeView.SelectedNode.Name == "TestCase" && e.KeyCode == Keys.Delete) { MSHandler.deleteTestCaseNode(CurrentTestCaseNode.Index); ScriptTreeView.Nodes.Remove(ScriptTreeView.SelectedNode); } } public void AddComponentToolStripMenuItem_Click(object sender, EventArgs e) { if (ScriptTreeView.SelectedNode.Name == "ROOT") { eventToolStripMenuItem.Enabled = false; assertionToolStripMenuItem.Enabled = false; } else { eventToolStripMenuItem.Enabled = true; assertionToolStripMenuItem.Enabled = true; } } private void PlayToolStripMenuItem_Click(object sender, EventArgs e) { clearBackColor(root); if (ScriptTreeView.SelectedNode.Level == 0) PSHandler.issuePlayCommand(); else if (ScriptTreeView.SelectedNode.Level == 1) PSHandler.issuePlayCommand(ScriptTreeView.SelectedNode.Index); } private void SetToolStripMenuItem_Click(object sender, EventArgs e) { ACf = new AddConfiguration(); ACf.ShowDialog(); PSHandler.assignConfiguration(ACf.Property_AUTName, ACf.Property_AUTPath); CheckIsButtonEnable(); } private void expandAllToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode OriginalSelectedNode = ScriptTreeView.SelectedNode; ScriptTreeView.ExpandAll(); ScriptTreeView.SelectedNode = OriginalSelectedNode; } public void ErrorUpdate()

  • ~ 56 ~ 

    { root.Nodes[PSHandler.Property_script.Property_CurrentTestNodeIndex].Nodes[PSHandler.Property_script.Property_ErrorIndex].BackColor = Color.Pink; } public void CorrectUpdate() { root.Nodes[PSHandler.Property_script.Property_CurrentTestNodeIndex].Nodes[PSHandler.Property_script.Property_CorrectIndex].BackColor = Color.GreenYellow; } public void TestCaseUpdate() { if (PSHandler.Property_script.Property_isTestCaseError) { root.Nodes[PSHandler.Property_script.Property_CurrentTestNodeIndex].BackColor = Color.Pink; if (ScriptTreeView.SelectedNode == root) root.BackColor = Color.Pink; } else { root.Nodes[PSHandler.Property_script.Property_CurrentTestNodeIndex].BackColor = Color.GreenYellow; if (root.BackColor != Color.Pink && ScriptTreeView.SelectedNode == root) root.BackColor = Color.GreenYellow; } } private void clearBackColor(TreeNode node) { if (node.GetNodeCount(false) == 0) { node.BackColor = Color.Empty; } else { for (int i = 0; i < node.GetNodeCount(false); i++) { node.BackColor = Color.Empty; clearBackColor(node.Nodes[i]); } } } private void TreeviewAddNode(TreeNode selected, TreeNode node) { int selectedLevel = selected.Level; if (selectedLevel == 0) { selected.Nodes.Add(node); } else if (selectedLevel == 1) { selected.Nodes.Add(node); } else if (selectedLevel == 2) { int selectedindex = selected.Index; selected = selected.Parent; selected.Nodes.Insert(selectedindex + 1, node); } else if (selectedLevel == 3) { selected = selected.Parent;//back到Lilevel 2 TreeviewAddNode(selected, node); } else if (selectedLevel == 4) { selected = selected.Parent.Parent;//back到Lilevel 2 TreeviewAddNode(selected, node); } } private void SaveToolStripMenuItem_Click(object sender, EventArgs e) { string selectedPath = ""; FolderBrowserDialog ChooseFolderDialog = new FolderBrowserDialog(); if (ChooseFolderDialog.ShowDialog() == DialogResult.OK) { selectedPath = ChooseFolderDialog.SelectedPath; bool isSuccess = MSHandler.assignStoreLocation(selectedPath); } } private void LoadToolStripMenuItem_Click(object sender, EventArgs e) {

  • ~ 57 ~ 

    // openDialog will be disposed while leaving using block using (OpenFileDialog openDialog = new OpenFileDialog()) { openDialog.Filter = "Graphic Objects files (*.gof)|*.gof"; // Handle filename and start to read if (openDialog.ShowDialog() == DialogResult.OK) { if (doc != null) doc.RemoveAll(); doc = new XmlDocument(); doc.Load(openDialog.FileName); buildScriptModel(); } } } private void buildScriptModel() { ScriptTreeView.Nodes.Clear(); MSHandler.clearScript(); root = new TreeNode(); root.Name = "ROOT"; root.Text = "ROOT"; ScriptTreeView.Nodes.Add(root); List Script_tcList = MSHandler.LoadFile(doc); for (int i = 0; i < Script_tcList.Count; i++) { ScriptInsertTestCase(Script_tcList[i].Property_TestCaseName); for (int j = 0; j < Script_tcList[i].Property_ItemList.Count; j++) { currentItem = Script_tcList[i].Property_ItemList[j]; if (currentItem.Property_Event != "") ScriptAddEvent(); else if (currentItem.Property_Method != "") ScriptInsertAssertion(); } } } } }

    6.2.3 AddCheckValue.cs using System; using System.Collections.Generic;

  • ~ 58 ~ 

    using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Web; using System.Windows.Forms; namespace GUITestTool { class AddCheckValue : Form { private Button button1; private Button button2; private Label label1; private TextBox textBox1; private string CheckValue; //private void InitializeComponent() public AddCheckValue() { FormBorderStyle = FormBorderStyle.FixedDialog; StartPosition = FormStartPosition.CenterParent; CheckValue = ""; this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(100, 12); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(130, 22); this.textBox1.TabIndex = 0; // // button1 // this.button1.Location = new System.Drawing.Point(67, 41); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 1; this.button1.Text = "確T定w"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(148, 40); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 2; this.button2.Text = "取Lu消o"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(29, 15); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(35, 12); this.label1.TabIndex = 3; this.label1.Text = "CheckValue:"; // // AddName // this.ClientSize = new System.Drawing.Size(255, 92); this.Controls.Add(this.label1); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.Name = "AddCheckValue"; this.Text = "CheckValue"; this.ResumeLayout(false); this.PerformLayout(); } private void button1_Click(object sender, EventArgs e) { Property_CheckValue = textBox1.Text.ToString(); Close(); }

  • ~ 59 ~ 

    private void button2_Click(object sender, EventArgs e) { Close(); } public string Property_CheckValue { set { CheckValue = value; } get { return CheckValue; } } } }

    6.2.4 AddComponent.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Web; using System.Windows.Forms; namespace GUITestTool { class AddCheckValue : Form { private Button button1; private Button button2; private Label label1; private TextBox textBox1; private string CheckValue; //private void InitializeComponent() public AddCheckValue() { FormBorderStyle = FormBorderStyle.FixedDialog; StartPosition = FormStartPosition.CenterParent; CheckValue = ""; this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(100, 12); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(130, 22); this.textBox1.TabIndex = 0; // // button1 // this.button1.Location = new System.Drawing.Point(67, 41); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 1; this.button1.Text = "確T定w"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(148, 40); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 2; this.button2.Text = "取Lu消o"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // label1

  • ~ 60 ~ 

    // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(29, 15); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(35, 12); this.label1.TabIndex = 3; this.label1.Text = "CheckValue:"; // // AddName // this.ClientSize = new System.Drawing.Size(255, 92); this.Controls.Add(this.label1); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.Name = "AddCheckValue"; this.Text = "CheckValue"; this.ResumeLayout(false); this.PerformLayout(); } private void button1_Click(object sender, EventArgs e) { Property_CheckValue = textBox1.Text.ToString(); Close(); } private void button2_Click(object sender, EventArgs e) { Close(); } public string Property_CheckValue { set { CheckValue = value; } get { return CheckValue; } } } }

    6.2.5 AddConfiguration.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Web; using System.Windows.Forms; namespace GUITestTool { class AddConfiguration : Form { private Button button1; private Button button2; private Label label1; private TextBox textBox1; private Label LocationLabel; private TextBox textBox2; private Button button3; private OpenFileDialog openFileDialog1; private string AUTName; private string AUTPath; //private void InitializeComponent() public AddConfiguration() { FormBorderStyle = FormBorderStyle.FixedDialog; StartPosition = FormStartPosition.CenterParent; this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.LocationLabel = new System.Windows.Forms.Label();

  • ~ 61 ~ 

    this.textBox2 = new System.Windows.Forms.TextBox(); this.button3 = new System.Windows.Forms.Button(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.SuspendLayout(); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(87, 12); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(156, 22); this.textBox1.TabIndex = 0; // // button1 // this.button1.Location = new System.Drawing.Point(56, 102); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 1; this.button1.Text = "確T定w"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(151, 102); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 2; this.button2.Text = "取Lu消o"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(29, 15); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(56, 12); this.label1.TabIndex = 3; this.label1.Text = "TitleName:"; // // LocationLabel // this.LocationLabel.AutoSize = true; this.LocationLabel.Location = new System.Drawing.Point(29, 57); this.LocationLabel.Name = "LocationLabel"; this.LocationLabel.Size = new System.Drawing.Size(49, 12); this.LocationLabel.TabIndex = 4; this.LocationLabel.Text = "Location:"; // // textBox2 // this.textBox2.Location = new System.Drawing.Point(87, 54); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(156, 22); this.textBox2.TabIndex = 5; // // button3 // this.button3.Location = new System.Drawing.Point(249, 53); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(54, 23); this.button3.TabIndex = 6; this.button3.Text = "瀏s覽y"; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // // openFileDialog1 // this.openFileDialog1.FileName = "openFileDialog1"; // // AddConfiguration // this.ClientSize = new System.Drawing.Size(315, 137); this.Controls.Add(this.button3); this.Controls.Add(this.textBox2); this.Controls.Add(this.LocationLabel); this.Controls.Add(this.label1); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.Name = "AddConfiguration"; this.Text = "Configuration"; this.ResumeLayout(false); this.PerformLayout(); }

  • ~ 62 ~ 

    private void button1_Click(object sender, EventArgs e) { Property_AUTName = textBox1.Text.ToString(); Property_AUTPath = textBox2.Text.ToString(); Close(); } private void button2_Click(object sender, EventArgs e) { Close(); } public string Property_AUTName { set { AUTName = value; } get { return AUTName; } } public string Property_AUTPath { set { AUTPath = value; } get { return AUTPath; } } private void button3_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { this.textBox2.Text = openFileDialog1.FileName; } } } }

    6.2.6 AddEvent.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing; using System.Diagnostics; namespace GUITestTool { class AddEvent : Form { private ListBox listBox1; private Button button1; private Button button2; private int index = -1; //private void InitializeComponent() public AddEvent(List Elements) { FormBorderStyle = FormBorderStyle.FixedDialog; StartPosition = FormStartPosition.CenterParent; this.listBox1 = new System.Windows.Forms.ListBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // listBox1 // this.listBox1.FormattingEnabled = true; this.listBox1.ItemHeight = 12; foreach (string Element in Elements) {

  • ~ 63 ~ 

    this.listBox1.Items.AddRange(new object[] { Element }); } this.listBox1.Location = new System.Drawing.Point(12, 12); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(260, 208); this.listBox1.TabIndex = 0; // // button1 // this.button1.Location = new System.Drawing.Point(42, 227); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 1; this.button1.Text = "確T定w"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(148, 227); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 2; this.button2.Text = "取Lu消o"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // AddComponent // this.ClientSize = new System.Drawing.Size(284, 264); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.listBox1); this.Name = "AddEvent"; this.Text = "Event"; this.ResumeLayout(false); } public int Property_index { set { index = value; } get { return index; } } private void button1_Click(object sender, EventArgs e) { Property_index = listBox1.SelectedIndex; Close(); } private void button2_Click(object sender, EventArgs e) { Close(); } } }

    6.2.7 AddMethod.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing; using System.Diagnostics; namespace GUITestTool { class AddMethod : Form { private ListBox listBox1; private Button button1; private Button button2; private int index = -1;

  • ~ 64 ~ 

    //private void InitializeComponent() public AddMethod(List Elements) { FormBorderStyle = FormBorderStyle.FixedDialog; StartPosition = FormStartPosition.CenterParent; this.listBox1 = new System.Windows.Forms.ListBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // listBox1 // this.listBox1.FormattingEnabled = true; this.listBox1.ItemHeight = 12; foreach (string Element in Elements) { this.listBox1.Items.AddRange(new object[] { Element }); } this.listBox1.Location = new System.Drawing.Point(12, 12); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(260, 208); this.listBox1.TabIndex = 0; // // button1 // this.button1.Location = new System.Drawing.Point(42, 227); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 1; this.button1.Text = "確T定w"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(148, 227); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 2; this.button2.Text = "取Lu消o"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // AddComponent // this.ClientSize = new System.Drawing.Size(284, 264); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.listBox1); this.Name = "AddMethod"; this.Text = "Method"; this.ResumeLayout(false); } public int Property_index { set { index = value; } get { return index; } } private void button1_Click(object sender, EventArgs e) { Property_index = listBox1.SelectedIndex; Close(); } private void button2_Click(object sender, EventArgs e) { Close(); } } }

    6.2.8 AddName.cs

  • ~ 65 ~ 

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Web; using System.Windows.Forms; namespace GUITestTool { class AddName : Form { private Button OK_Button; private Button Cancel_Button; private Label NameLabel; private TextBox NameTextBox; private string IdName; //private void InitializeComponent() public AddName() { FormBorderStyle = FormBorderStyle.FixedDialog; StartPosition = FormStartPosition.CenterParent; IdName = ""; this.NameTextBox = new System.Windows.Forms.TextBox(); this.OK_Button = new System.Windows.Forms.Button(); this.Cancel_Button = new System.Windows.Forms.Button(); this.NameLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // textBox1 // this.NameTextBox.Location = new System.Drawing.Point(67, 12); this.NameTextBox.Name = "textBox1"; this.NameTextBox.Size = new System.Drawing.Size(156, 22); this.NameTextBox.TabIndex = 0; // // button1 // this.OK_Button.Location = new System.Drawing.Point(67, 41); this.OK_Button.Name = "button1"; this.OK_Button.Size = new System.Drawing.Size(75, 23); this.OK_Button.TabIndex = 1; this.OK_Button.Text = "確T定w"; this.OK_Button.UseVisualStyleBackColor = true; this.OK_Button.Click += new System.EventHandler(this.OKButton_Click); // // button2 // this.Cancel_Button.Location = new System.Drawing.Point(148, 40); this.Cancel_Button.Name = "button2"; this.Cancel_Button.Size = new System.Drawing.Size(75, 23); this.Cancel_Button.TabIndex = 2; this.Cancel_Button.Text = "取Lu消o"; this.Cancel_Button.UseVisualStyleBackColor = true; this.Cancel_Button.Click += new System.EventHandler(this.CancelButton_Click); // // label1 // this.NameLabel.AutoSize = true; this.NameLabel.Location = new System.Drawing.Point(29, 15); this.NameLabel.Name = "label1"; this.NameLabel.Size = new System.Drawing.Size(35, 12); this.NameLabel.TabIndex = 3; this.NameLabel.Text = "Name:"; // // AddName // this.ClientSize = new System.Drawing.Size(255, 92); this.Controls.Add(this.NameLabel); this.Controls.Add(this.Cancel_Button); this.Controls.Add(this.OK_Button); this.Controls.Add(this.NameTextBox); this.Name = "AddName"; this.Text = "Name"; this.ResumeLayout(false); this.PerformLayout(); } private void OKButton_Click(object sender, EventArgs e) { Property_IdName = NameTextBox.Text.ToString();

  • ~ 66 ~ 

    Close(); } private void CancelButton_Click(object sender, EventArgs e) { Close(); } public string Property_IdName { set { IdName = value; } get { return IdName; } } } }

    6.2.9 AddParameter.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Web; using System.Windows.Forms; namespace GUITestTool { class AddParameter : Form { private Button OK_Button; private Button Cancel_Button; private Label ParameterLabel; private TextBox ParameterTextBox; private string Parameter; //private void InitializeComponent() public AddParameter() { FormBorderStyle = FormBorderStyle.FixedDialog; StartPosition = FormStartPosition.CenterParent; Parameter = ""; this.ParameterTextBox = new System.Windows.Forms.TextBox(); this.OK_Button = new System.Windows.Forms.Button(); this.Cancel_Button = new System.Windows.Forms.Button(); this.ParameterLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // textBox1 // this.ParameterTextBox.Location = new System.Drawing.Point(100, 12); this.ParameterTextBox.Name = "textBox1"; this.ParameterTextBox.Size = new System.Drawing.Size(130, 22); this.ParameterTextBox.TabIndex = 0; // // button1 // this.OK_Button.Location = new System.Drawing.Point(67, 41); this.OK_Button.Name = "button1"; this.OK_Button.Size = new System.Drawing.Size(75, 23); this.OK_Button.TabIndex = 1; this.OK_Button.Text = "確T定w"; this.OK_Button.UseVisualStyleBackColor = true; this.OK_Button.Click += new System.EventHandler(this.OKButton_Click); // // button2 // this.Cancel_Button.Location = new System.Drawing.Point(148, 40); this.Cancel_Button.Name = "button2"; this.Cancel_Button.Size = new System.Drawing.Size(75, 23); this.Cancel_Button.TabIndex = 2; this.Cancel_Button.Text = "取Lu消o"; this.Cancel_Button.UseVisualStyleBackColor = true; this.Cancel_Button.Click += new System.EventHandler(this.CancelButton_Click); //

  • ~ 67 ~ 

    // label1 // this.ParameterLabel.AutoSize = true; this.ParameterLabel.Location = new System.Drawing.Point(29, 15); this.ParameterLabel.Name = "label1"; this.ParameterLabel.Size = new System.Drawing.Size(35, 12); this.ParameterLabel.TabIndex = 3; this.ParameterLabel.Text = "Parameter:"; // // AddName // this.ClientSize = new System.Drawing.Size(255, 92); this.Controls.Add(this.ParameterLabel); this.Controls.Add(this.Cancel_Button); this.Controls.Add(this.OK_Button); this.Controls.Add(this.ParameterTextBox); this.Name = "AddParameter"; this.Text = "Parameter"; this.ResumeLayout(false); this.PerformLayout(); } private void OKButton_Click(object sender, EventArgs e) { Property_Parameter = ParameterTextBox.Text.ToString(); Close(); } private void CancelButton_Click(object sender, EventArgs e) { Close(); } public string Property_Parameter { set { Parameter = value; } get { return Parameter; } } } }

    6.2.10 AddTestCaseName.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Web; using System.Windows.Forms; namespace GUITestTool { class AddTestCaseName : Form { private Button OK_Button; private Button Cancel_Button; private Label NameLabel; private TextBox NameTextBox; private string TestCaseName; //private void InitializeComponent() public AddTestCaseName() { FormBorderStyle = FormBorderStyle.FixedDialog; StartPosition = FormStartPosition.CenterParent; TestCaseName = "";