Class: Case
- Inherits:
-
Object
- Object
- Case
- Defined in:
- lib/teuton/case/case.rb,
lib/teuton/case/host.rb,
lib/teuton/case/play.rb,
lib/teuton/case/close.rb,
lib/teuton/case/config.rb,
lib/teuton/case/builtin/main.rb
Defined Under Namespace
Constant Summary collapse
- @@id =
First case ID value
"01"
Instance Attribute Summary collapse
-
#action ⇒ Object
Updated by ExecuteManager.
-
#config ⇒ Object
readonly
Readed by ExecuteManager.
-
#conn_status ⇒ Object
Updated by ExecuteManager.
-
#id ⇒ Object
readonly
Readed by ExecuteManager.
-
#result ⇒ Object
Updated by ExecuteManager.
-
#sessions ⇒ Object
Updated by ExecuteManager.
-
#skip ⇒ Object
(also: #skip?)
readonly
Readed by ExecuteManager.
-
#uniques ⇒ Object
readonly
Readed by ExecuteManager.
Instance Method Summary collapse
- #close(uniques) ⇒ Object
- #export(format) ⇒ Object
- #filename ⇒ Object
- #grade ⇒ Object
- #host(host = "localhost") ⇒ Object
-
#initialize(config) ⇒ Case
constructor
A new instance of Case.
- #members ⇒ Object
-
#play ⇒ Object
(also: #start)
READ: sessions, config, groups, action, report TODO: groups from Project or from Case???.
Methods included from Verbose
Methods included from DSL
#expect, #expect2, #expect_any, #expect_exit, #expect_fail, #expect_first, #expect_last, #expect_none, #expect_nothing, #expect_ok, #expect_one, #expect_sequence, #get, #get_host, #gett, #goto, #log, #macro, #method_missing, #readme, #remote_tempdir, #remote_tempfile, #respond_to_missing?, #run, #run_script, #send, #set, #target, #tempdir, #tempfile, #unique, #unset, #upload, #upload_one, #weight
Constructor Details
#initialize(config) ⇒ Case
Returns a new instance of Case.
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 63 64 65 |
# File 'lib/teuton/case/case.rb', line 25 def initialize(config) @config = Case::Config.new( local: config, global: Project.value[:global] ) @groups = Project.value[:groups] @id = @@id @@id = @@id.next # Define Case Report @report = Report.new(@id) @report.output_dir = File.join("var", @config.global[:tt_testname]) # Default configuration @skip = false @skip = get(:tt_skip) unless get(:tt_skip) == "NODATA" unless Project.value[:options]["case"].nil? @skip = true @skip = false if Project.value[:options]["case"].include? @id.to_i end @debug = Project.debug? @verbose = Project.value[:verbose] @tmpdir = File.join("var", @config.get(:tt_testname), "tmp", @id.to_s) # ensure_dir @tmpdir # REVISE: When we will need this? Samba? @unique_values = {} @result = Result.new @action_counter = 0 @action = { id: 0, weight: 1.0, description: "No description!", groupname: nil } @uniques = [] @sessions = {} # Store opened sessions for this case @conn_status = {} tempfile :default end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DSL
Instance Attribute Details
#action ⇒ Object
Updated by ExecuteManager
19 20 21 |
# File 'lib/teuton/case/case.rb', line 19 def action @action end |
#config ⇒ Object (readonly)
Readed by ExecuteManager
21 22 23 |
# File 'lib/teuton/case/case.rb', line 21 def config @config end |
#conn_status ⇒ Object
Updated by ExecuteManager
19 20 21 |
# File 'lib/teuton/case/case.rb', line 19 def conn_status @conn_status end |
#id ⇒ Object (readonly)
Readed by ExecuteManager
21 22 23 |
# File 'lib/teuton/case/case.rb', line 21 def id @id end |
#result ⇒ Object
Updated by ExecuteManager
19 20 21 |
# File 'lib/teuton/case/case.rb', line 19 def result @result end |
#sessions ⇒ Object
Updated by ExecuteManager
19 20 21 |
# File 'lib/teuton/case/case.rb', line 19 def sessions @sessions end |
#skip ⇒ Object (readonly) Also known as: skip?
Readed by ExecuteManager
21 22 23 |
# File 'lib/teuton/case/case.rb', line 21 def skip @skip end |
#uniques ⇒ Object (readonly)
Readed by ExecuteManager
21 22 23 |
# File 'lib/teuton/case/case.rb', line 21 def uniques @uniques end |
Instance Method Details
#close(uniques) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/teuton/case/close.rb', line 4 def close(uniques) # Invoked from check_cases! fails = 0 @uniques.each do |key| next unless uniques[key].include?(id) && uniques[key].count > 1 fails += 1 (key, uniques[key]) end @report.tail[:unique_fault] = fails @report.close end |
#export(format) ⇒ Object
67 68 69 70 71 |
# File 'lib/teuton/case/case.rb', line 67 def export(format) return if skip? @report.export format end |
#filename ⇒ Object
73 74 75 76 |
# File 'lib/teuton/case/case.rb', line 73 def filename # called from: close_main_report @report.filename end |
#grade ⇒ Object
78 79 80 81 82 |
# File 'lib/teuton/case/case.rb', line 78 def grade return 0.0 if skip @report.tail[:grade] end |
#host(host = "localhost") ⇒ Object
4 5 6 |
# File 'lib/teuton/case/builtin/main.rb', line 4 def host(host = "localhost") TeutonHost.new(self, host) end |
#members ⇒ Object
84 85 86 87 88 |
# File 'lib/teuton/case/case.rb', line 84 def members return "-" if skip @report.head[:tt_members] || "noname" end |
#play ⇒ Object Also known as: start
READ: sessions, config, groups, action, report TODO: groups from Project or from Case???
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/teuton/case/play.rb', line 6 def play if skip? verbose Rainbow("S").green return false end start_time = Time.now play_groups_in_sequence fill_report(start_time, Time.now) close_opened_sessions end |