1. Preface
    1. About MarathonITE
    2. Supported Platforms
      1. Java/Swing™
      2. Java/FX™
      3. Web Applications
    3. What's New in MarathonITE 5.0
    4. Change Log a.k.a Version History
    5. System Requirements
    6. Copyright Notice
  2. Getting Started
    1. Introduction to Test Automation
      1. Unattended Testing
      2. Semi Automated Testing
      3. Exploratory Testing
    2. MarathonITE Projects
    3. Your First Project
      1. Java/Swing™ Test Project
        1. Application Under Test - SwingSet3
        2. Creating a Project
        3. Recording a Test
        4. Anatomy of a Test Script
        5. Running Tests
        6. Looking at Results
      2. Java/FX™ Test Project
        1. Application Under Test - Ensemble
        2. Creating a Project
        3. Recording a Test
        4. Anatomy of a Test Script
        5. Running Tests
        6. Looking at Results
      3. Web Application Test Project
        1. Application Under Test - DuckDuckGo Search
        2. Creating a Project
        3. Recording a Test
        4. Anatomy of a Test Script
        5. Running Tests
        6. Looking at Results
    4. MarathonITE Sample Projects
  3. User Guide
    1. Installation and Startup
    2. MarathonITE User Interface
      2. Editors
      3. Output Views
    3. Creating Marathonite Test Projects
    4. Recording Tests
    5. Managing Checklists
    6. Exploratory Tests
    7. Semi Automated Tests
    8. Executing Tests
      1. Executing a Test from Editor
        1. Debugging Scripts
        2. Using Script Console
      2. Executing Tests from Test Runner
      3. Executing Tests in Batch Mode
    9. Organizing Tests
      1. Organizing Tests in Folder Heirarchy
      2. Organizing Tests as Features and Stories
      3. Organizing Tests in Suites
      4. Linking Tests to TMS and Issue Manager
    10. Modularizing Test Scripts
      1. Module Methods
      2. Extract Method Refactoring
      3. Using Data Loops
      4. Convert to Data Loop Refactoring
    11. Data Driven Tests
      1. Convert to DDT Refactoring
  4. Advanced Scripting
    1. Ruby Programming Language
    2. Marathon and Ruby
    3. Selenium/WebDriver Bindings
      1. Java/Swing™ Components
      2. Java/FX™ Controls

3.10.Modularizing Test Scripts

Marathon supports modules - set of methods that can be called from within a test script. Modules improve reusability of script,
since a single module method can be used in multiple places. Marathon modules are regular ruby script files with a set
of methods. The difference between regular ruby modules and Marathon modules is that you can insert a Marathon module
method while recording a script.

Using Marathon you can create templates for a module method and save them. MarathonITE provides an Extract Module refactoring
using which you can easily create a module method.

In this chapter after a quick look at advantages of refactoring scripts you will see how you can create modules in Marathon.

Why Modularizing?

Modularizing is the act of splitting a test script into methods. Using methods in a test script makes it easier
to read and understand it. Methods also allow you to avoid duplication and the insert script Marathon action while recording,
allows you to reuse the methods even while recording a test script.

There are many valid reasons for creating a method. Let us enumerate some of them here.

1. Reducing complexity

You need to think about what is inside a method while developing or changing the method itself, but once a method is written
you just use it.

2. Avoiding duplicate code

By extracting the code into a common method (may be with some parameters) you can avoid duplication.

3. Isolate changes

Suppose you have a dialog where you enter user details. What happens when the dialog is changed? If the enter user details
operation is in a method even though it may have been used hundreds of times - you need to modify only a single method.

4. Isolating operations on custom components

There comes a time when you need to support a custom component in your test project. Fortunately, Marathon facilitates accessing
the underlying Java component. You can access that component and perform the operations. But what happens when you need
to do this in a lot of test scripts? Pull that part of code as a module method and you can use insert script command
to perform all the jugglery.

5. Script readability

It's easier to understand when a certain code is extracted to a method rather than going through all the code.

Suggest Edit
Close Menu