coba-testrunner 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/coba +41 -1
  3. data/lib/coba-testrunner.rb +10 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7015060ab5065ef95f260bde042f5b0caf42dceb
4
- data.tar.gz: d31cbf08a768a0c370fffb60647e6c9d56ee9f32
3
+ metadata.gz: afb7ac3f42557a11bd2cd0991fc9cae25f56e673
4
+ data.tar.gz: 1cf8f79db27018400d8c414da3618687b16cdcdc
5
5
  SHA512:
6
- metadata.gz: c50e8bdf886fa8cfc2bc59ac399b2ffa62817b42158b39d9efa1828982213c22585643bdd94fdfe6b1664b3bfca6463e565ad47bd375dd160235aa5e6bbf2247
7
- data.tar.gz: 6ce5652e322a7a4432c4ad9ee58e307bea86558349bb138be3651dd248b352618edfd846dcaa212ca91f49fb24e612ac9ff4b4712b77385ba1adbb65092470ff
6
+ metadata.gz: 6d59a7cc50270cea429a71b7fb492942e0c8d78088ec423c9249684bcc9172bd33ddd5a770fcef0ab59a0d5447ee2162af753df44516953e5a9931254a1ee86a
7
+ data.tar.gz: a6159541a9e39e601c67e42dbfce952a6274be7f2cee0111b1c8c9ee262e3245ec6d6dfd8d8362f71f607538a9a9ec172661bad728f07ca3b052fc31824c52bb
data/bin/coba CHANGED
@@ -50,7 +50,7 @@ class Coba < Thor
50
50
  # Array loop
51
51
  arrayOfBrowser = Array.new
52
52
 
53
- if browser.empty?
53
+ if browser === nil
54
54
  browser = config['browsers']
55
55
  end
56
56
 
@@ -146,6 +146,46 @@ class Coba < Thor
146
146
  dir = File.dirname(File.expand_path(__FILE__))
147
147
  FileUtils.copy_entry dir+"/../lib/template/", Dir.pwd+"/"
148
148
  end
149
+
150
+ desc "split file chunk", "Split big testcase into some little file"
151
+ long_desc <<-LONGDESC
152
+ coba split will split big testcase file into several file so you can test it chunck by chunk
153
+ chunk is testcase length
154
+
155
+ ex :\n
156
+ > $./coba split 128
157
+ LONGDESC
158
+ def split(file, chunk)
159
+ puts "Spliting file"
160
+
161
+ if File.exist?(file)
162
+ testFile = File.read(file)
163
+ else
164
+ raise "File #{file} doesn't exist"
165
+ end
166
+
167
+ testCases = JSON.parse(testFile)
168
+ puts "Test Cases Count : #{testCases.length}"
169
+
170
+ count = testCases.length / chunk.to_f
171
+ count = count.ceil
172
+
173
+ chunkTestCases = []
174
+ testCases.each.with_index(1) do |testCase,testIndex|
175
+ chunkTestCases << testCase
176
+ if (testIndex % chunk.to_i) === 0 || testIndex === testCases.length
177
+ filename = File.basename(file,".json")
178
+ number = (testIndex / chunk.to_f).ceil
179
+ puts "Compiling Test Cases : #{number} of #{count}"
180
+ File.open("#{Dir.pwd}/#{filename}-#{number.to_i}-of-#{count}.json","w") do |f|
181
+ f.write(JSON.pretty_generate chunkTestCases)
182
+ end
183
+ chunkTestCases = []
184
+ end
185
+ end
186
+ puts "Spliting file finished"
187
+ end
188
+
149
189
  end
150
190
 
151
191
  Coba.start(ARGV)
@@ -41,6 +41,10 @@ class TestRunner
41
41
  def start(testCase=nil)
42
42
  @testCase = testCase
43
43
 
44
+ if(@config['overrideConfig'] === true)
45
+ @config = overrideConfig(@config,@testCase)
46
+ end
47
+
44
48
  beforeExecution
45
49
 
46
50
  loadUrl(@config['startingUrl'])
@@ -60,6 +64,10 @@ class TestRunner
60
64
  end
61
65
 
62
66
  private #Private method dibawah
67
+ def overrideConfig(config,testCases)
68
+ config['startingUrl'] = testCases['testCases']['startingUrl'];
69
+ return config;
70
+ end
63
71
  def logTime(index,start,finish)
64
72
  @time[index] = Hash.new
65
73
  @time[index]['start'] = start
@@ -72,9 +80,9 @@ class TestRunner
72
80
 
73
81
  start = Time.new
74
82
 
75
- if @config['before'] and File.exist?(@config['before']) and url
83
+ if @config['before'] and File.exist?(@config['before']) and !url.nil?
76
84
  @driver.navigate.to url
77
- elsif url
85
+ elsif !url.nil?
78
86
  @driver.get url
79
87
  end
80
88
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coba-testrunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunu Pinasthika Fajar