Module: Main
- Defined in:
- lib/main.rb
Overview
Created on 20 Sept 2017 @author: Andy Perrett
Versions: 1.0 - Baseline
main.rb - Framework Driver Script
Class Method Summary collapse
Class Method Details
.cmdline_input ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/main.rb', line 13 def self.cmdline_input # check if the test suite file name exists on the command line # allow a user to input 2 arguments in to CMD line the 2 values are: # Testcase Folder and Browser. = {} ARGV.push('-h') if ARGV.empty? OptionParser.new do |parser| # Whenever we see -b, -t or --browser, or --tests with an # argument, save the argument. parser. = 'Usage: taf [options]' parser.on( '-h', '--help', "2 arguments are required: {Browser} {Testcase folder}'" ) do puts parser Process.exit end parser.on( '-b', '--browser browser', 'Supported Browsers: chrome,' \ ' chrome-headless, firefox, firefox-headless.' ) do |b| [:browser] = b $browserType = [:browser] unless ['chrome', 'chrome-headless', 'firefox', 'firefox-headless'] .include?($browserType) MyLog.log.warn 'A valid Browser has not been supplied as a' \ ' command-line parameter as expected' Process.exit end end parser.on('-t', '--tests testfolder', 'i.e. tests/') do |t| [:testfolder] = t $testcasesFolder = [:testfolder] if Parser.test_files.size.positive? MyLog.log.info "There are: #{Parser.test_files.size}" \ ' test files to process' MyLog.log.info "List of Tests files: #{Parser.test_files} \n" else MyLog.log.warn 'A valid Test case location has not been supplied' \ ' as a command-line parameter as expected' Process.exit end end end.parse! end |