TMC Test Framework

Table of Contents

  1. Development Environment
  2. Tips & Tricks

Development Environment

Basic Setup

Follow these instructions to set up a TMC test framework development environment:

  1. Download and install Ruby 2.4.3-1 64-bit for Windows. Follow prompts to install MSYS2.
  2. Make sure the correct gems are installed. Navigate to the Ruby "bin" folder, then paste:

    Windows

    gem.cmd install nokogiri -v 1.8.0
    gem.cmd install minitest -v 5.10.3
    gem.cmd install selenium-client -v 1.2.18
    gem.cmd install snmp -v 1.2.0
    gem.cmd install aws-sdk-s3 -v 1.8.0
    

    Mac OS

    sudo ./gem install nokogiri -v 1.8.0
    sudo ./gem install minitest -v 5.10.3
    sudo ./gem install selenium-client -v 1.2.18
    sudo ./gem install snmp -v 1.2.0
    sudo ./gem install aws-sdk-s3 -v 1.8.0
    
  3. Install a Git client and clone this repository (use HTTPS clone URL).

  4. Install and configure a Ruby IDE (see VS Code Setup or IntelliJ Setup).

  5. To run tests, you must execute run_test.rb from the top-level directory with script arguments:

    >ruby.exe run_test.rb path=<script path> devices=<device> id=<test id> job=<job id> level=<log level> host=<tmc ip> auth=<base-64 auth token>
    

    Example run command:

    >ruby.exe run_test.rb path=test_cases/sandbox/sandbox.rb devices=1 id=1 job=166d813a-7f36-448e-9e16-f99848ccc38e level=debug host=10.143.27.81 auth=dHd******3IQ==
    

[Back to top]

VS Code Setup

Follow these instructions to configure VS Code for TMC test framework development:

  1. Install Visual Studio Code.
  2. Launch VS Code and install the Ruby extension via Extensions (Ctrl+Shift+X).
  3. Follow the instructions in the documentation for the Ruby extension; typically you will need to install the following gems: ruby-debug-ide, debase, rcodetools, rubocop.
  4. Enable the Ruby helpers via File > Preferences > Settings, search for "ruby", and configure the following:
    • Ruby: Code Completion => rcodetools
    • Ruby: Format => rubocop
    • Ruby: Intellisense => rubyLocate
    • (if you have multiple Rubies installed) Ruby > Interpreter: Command Path => c:/Ruby24-x64/bin/ruby
  5. Load the project via File > Open Folder and choose the location where you cloned the repository (usually "Development" or its parent folder).
  6. Select Debug > Add Configuration... and choose Ruby as the interpreter.
  7. In launch.json (should open automatically after the previous step), modify the configuration named Debug Local File as follows: { "name": "Debug Local File", "type": "Ruby", "request": "launch", "cwd": "${workspaceRoot}", "program": "${workspaceRoot}/run_test.rb", "args": [ "host=<tmc ip>", "id=<test id>", "devices=<device>", "job=<job id>", "level=<log level>", "path=<script path>, "auth=<base-64 auth token>" ] } Example: { "name": "Debug Local File", "type": "Ruby", "request": "launch", "cwd": "${workspaceRoot}", "program": "${workspaceRoot}/run_test.rb", "args": [ "host=twcltbeta.tmcserver.com", "id=1", "devices=2", "job=4cc977fa-f576-453e-90b1-90ec6600a9d7", "path=sandbox/sandbox.rb", "auth=Yy***Ts=" ] }
  8. Finally, select Debug (Ctrl+Shift+D), ensure Debug Local File is selected, and click the "play" button (F5) to start debugging.

[Back to top]

IntelliJ Setup

Follow these instructions to configure IntelliJ for TMC test framework development:

  1. Install IntelliJ.
  2. Launch IntelliJ and install the Ruby plugin via Settings > Plugins > Install Jetbrains Plugin.
  3. Create a new project via File > New Project > Ruby Module:

    i. Set Project Location to where you cloned the repository (usually "Development" or its parent folder)

    ii. Configure and select the Ruby SDK (use local path to ruby.exe).

  4. Open run_test.rb and run it. This will fail but will create a run configuration.

  5. Click Run > Edit Configurations, select the one named "run_test" and configure it as follows:

    i. Script arguments:

    path=<script path> devices=<device> id=<test id> job=<job id> level=<log level> host=<tmc ip> auth=<base-64 auth token>
    

    Example script arguments:

    path=test_cases/sandbox/sandbox.rb devices=1 id=1 job=166d813a-7f36-448e-9e16-f99848ccc38e level=debug host=10.143.27.81 auth=dHd******3IQ==
    

    ii. Working directory: Erase everything after "Development".

[Back to top]

Tips & Tricks

Helpful Git Commands

Alias for pruning local tags that do not exist in the remote:

alias git-prune-tags='git fetch --prune origin +refs/tags/*:refs/tags/*'

[Back to top]

Style

  • All Ruby code in the TMC test framework should adhere to this style guide.
  • As prescribed in the aforementioned Style Guide, all documentation should be formatted per TomDoc.

[Back to top]