Class: Testcase

Inherits:
Object
  • Object
show all
Defined in:
lib/testcase.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(testcase = nil) ⇒ Testcase

Returns a new instance of Testcase.



129
130
131
132
# File 'lib/testcase.rb', line 129

def initialize(testcase=nil)
  @testcase = testcase 
  @check = true
end

Instance Attribute Details

#checkObject

Returns the value of attribute check.



134
135
136
# File 'lib/testcase.rb', line 134

def check
  @check
end

#testcaseObject

Returns the value of attribute testcase.



134
135
136
# File 'lib/testcase.rb', line 134

def testcase
  @testcase
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


190
191
192
193
194
195
196
197
# File 'lib/testcase.rb', line 190

def exists?
  @result = self.find 
  if @result.empty?
    return false
  else
    return true
  end
end

#findObject



183
184
185
186
187
# File 'lib/testcase.rb', line 183

def find
  puts @testcase.inspect
  @result = $server.call("TestCase.list", @testcase)
  return @result
end

#get_plans(case_id) ⇒ Object



200
201
202
203
# File 'lib/testcase.rb', line 200

def get_plans(case_id)
  @result = $server.call("TestCase.list", case_id)
  return @result
end


178
179
180
# File 'lib/testcase.rb', line 178

def print
  puts @testcase.inspect
end

#read(id) ⇒ Object



172
173
174
175
# File 'lib/testcase.rb', line 172

def read(id)
  @testcase = $server.call("TestCase.get", id)
  return @testcase
end

#writeObject



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/testcase.rb', line 137

def write 
  if @testcase["summary"].nil?
    puts "Testcase summary needs to have some value"
    return false
  elsif @testcase["category"].nil?
    puts "Testcase category must be set"
    return false
  elsif @testcase["plans"].nil?
    puts "No testplans defined to add testcase"
    return false
  end
  if @testcase["priority"].nil?
    puts "Testcase priority not set. Using [P5 - None]"
    @testcase["priority"] = "P5 - None"
  end
  if @testcase["status"].nil?
    puts "Testcase status not set. Using [PROPOSED]"
    @testcase["status"] = "PROPOSED"
  end

  if @check
    if self.exists?
      puts "Testcase already existing - aborting"
      return false
    else
      @testcase = $server.call("TestCase.create", @testcase)
      return @testcase
    end
  else 
    @testcase = $server.call("TestCase.create", @testcase)
    return @testcase
  end
end