TMC Test Framework
Table of Contents
Development Environment
Basic Setup
Follow these instructions to set up a TMC test framework development environment:
- Download and install Ruby 2.4.3-1 64-bit for Windows. Follow prompts to install MSYS2.
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
Install a Git client and clone this repository (use HTTPS clone URL).
Install and configure a Ruby IDE (see VS Code Setup or IntelliJ Setup).
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==
VS Code Setup
Follow these instructions to configure VS Code for TMC test framework development:
- Install
Visual Studio Code
. - Launch VS Code and install the
Ruby
extension via Extensions (Ctrl+Shift+X). - 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
. - 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
- Ruby: Code Completion =>
- Load the project via File > Open Folder and choose the location where you cloned the repository (usually "Development" or its parent folder).
- Select Debug > Add Configuration... and choose
Ruby
as the interpreter. - In
launch.json
(should open automatically after the previous step), modify the configuration namedDebug 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=" ] }
- Finally, select Debug (Ctrl+Shift+D), ensure
Debug Local File
is selected, and click the "play" button (F5) to start debugging.
IntelliJ Setup
Follow these instructions to configure IntelliJ for TMC test framework development:
- Install IntelliJ.
- Launch IntelliJ and install the Ruby plugin via Settings > Plugins > Install Jetbrains Plugin.
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
).Open
run_test.rb
and run it. This will fail but will create a run configuration.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".
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/*'
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.