test_case_generator 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/parallel.testcase +22 -0
- data/lib/test_case_generator/cli.rb +2 -0
- data/lib/test_case_generator/dsl_context.rb +45 -0
- data/lib/test_case_generator/generator_java.rb +4 -9
- data/lib/test_case_generator/generator_javascript.rb +110 -0
- data/lib/test_case_generator/generator_objective_c.rb +2 -2
- data/lib/test_case_generator/generator_python.rb +2 -2
- data/lib/test_case_generator/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 656a3c2e29e60d4eab8d44b0c4d43c33ed8ae08c
|
4
|
+
data.tar.gz: 4468e1db4ea928e417869e4ae9666cee4e83ec68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6df9fd3d3dde363eb7a3159585f7287fa08f810bd4374042bf154bf167082f94a73b334e27f780cc4ac0a249fd47bfd442e1082beea86db930b6cda2432f848
|
7
|
+
data.tar.gz: 6f66ed720bdf352e70aa3253d1996a620eaf07972b3da778b6dc08705b19231788f504eff4fe0336c74de263441519dbcfc8e2238d7f7bbf75a457f1cd8c5ba9
|
@@ -0,0 +1,22 @@
|
|
1
|
+
before { |items|
|
2
|
+
items << :on_create
|
3
|
+
items << :on_start
|
4
|
+
}
|
5
|
+
|
6
|
+
parallel {
|
7
|
+
choice { |items|
|
8
|
+
items << []
|
9
|
+
items << [:on_resume, :on_pause]
|
10
|
+
}
|
11
|
+
|
12
|
+
choice { |items|
|
13
|
+
items << :data_changed
|
14
|
+
items << :network_error
|
15
|
+
items << :time_out
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
after { |items|
|
20
|
+
items << :on_stop
|
21
|
+
items << :on_destroy
|
22
|
+
}
|
@@ -7,6 +7,7 @@ require 'test_case_generator/generator_objective_c'
|
|
7
7
|
require 'test_case_generator/generator_java'
|
8
8
|
require 'test_case_generator/generator_php'
|
9
9
|
require 'test_case_generator/generator_python'
|
10
|
+
require 'test_case_generator/generator_javascript'
|
10
11
|
|
11
12
|
module TestCaseGenerator
|
12
13
|
class CLI < Thor
|
@@ -22,6 +23,7 @@ module TestCaseGenerator
|
|
22
23
|
factory.register TestCaseGenerator::GeneratorJava.new
|
23
24
|
factory.register TestCaseGenerator::GeneratorPHP.new
|
24
25
|
factory.register TestCaseGenerator::GeneratorPython.new
|
26
|
+
factory.register TestCaseGenerator::GeneratorJavaScript.new
|
25
27
|
|
26
28
|
gen = factory.query source_fn
|
27
29
|
gen.write ctx, source_fn
|
@@ -82,6 +82,51 @@ module TestCaseGenerator
|
|
82
82
|
end
|
83
83
|
alias_method :seq, :concat
|
84
84
|
|
85
|
+
def parallel(&block)
|
86
|
+
child_context = DSLContext.new
|
87
|
+
child_context.instance_eval &block
|
88
|
+
|
89
|
+
first = true
|
90
|
+
tmp = []
|
91
|
+
child_context.children.each do |ctx|
|
92
|
+
tmp2 = []
|
93
|
+
ctx.raw_each do |ptn|
|
94
|
+
if first
|
95
|
+
tmp2 << ptn
|
96
|
+
else
|
97
|
+
tmp.each do |x|
|
98
|
+
(0..x.length + ptn.length - 1).to_a.combination(x.length) do |index_arr|
|
99
|
+
x_index = 0
|
100
|
+
ptn_index = 0
|
101
|
+
tmp2 << (0..x.length + ptn.length - 1).map do |i|
|
102
|
+
if index_arr.include?(i)
|
103
|
+
ret = x[x_index]
|
104
|
+
x_index += 1
|
105
|
+
else
|
106
|
+
ret = ptn[ptn_index]
|
107
|
+
ptn_index += 1
|
108
|
+
end
|
109
|
+
|
110
|
+
ret
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
tmp = tmp2
|
118
|
+
first = false
|
119
|
+
end
|
120
|
+
|
121
|
+
tmp.each do |x|
|
122
|
+
@patterns << x
|
123
|
+
x.each do |label|
|
124
|
+
@labels << label unless @labels.include? label
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
alias_method :para, :parallel
|
129
|
+
|
85
130
|
def raw_each
|
86
131
|
@patterns.each { |ptn| yield @before + ptn + @after }
|
87
132
|
end
|
@@ -8,15 +8,14 @@ module TestCaseGenerator
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def write(ctx, source_fn)
|
11
|
-
write_skeleton source_fn unless File.
|
11
|
+
write_skeleton source_fn unless File.exist? source_fn
|
12
12
|
write_interface ctx, File.join(File.dirname(source_fn), make_interface_name(source_fn)) + '.java'
|
13
13
|
write_source ctx, source_fn
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
16
|
def make_class_name(filename)
|
18
17
|
# File.join(File.dirname(source_fn), File.basename(source_fn, File.extname(source_fn))
|
19
|
-
File.basename filename,
|
18
|
+
File.basename filename, '.*'
|
20
19
|
end
|
21
20
|
|
22
21
|
def make_interface_name(filename)
|
@@ -27,12 +26,8 @@ module TestCaseGenerator
|
|
27
26
|
parts = []
|
28
27
|
java_seen = false
|
29
28
|
File.absolute_path(File.dirname(filename)).split('/').each do |x|
|
30
|
-
if java_seen
|
31
|
-
|
32
|
-
end
|
33
|
-
if x == 'java'
|
34
|
-
java_seen = true
|
35
|
-
end
|
29
|
+
parts << x if java_seen
|
30
|
+
java_seen = true if x == 'java'
|
36
31
|
end
|
37
32
|
|
38
33
|
if parts.empty?
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'test_case_generator/dsl_context'
|
2
|
+
require 'test_case_generator/indented_writer'
|
3
|
+
|
4
|
+
module TestCaseGenerator
|
5
|
+
class GeneratorJavaScript
|
6
|
+
def can_handle?(source_fn)
|
7
|
+
File.extname(source_fn).eql? '.js'
|
8
|
+
end
|
9
|
+
|
10
|
+
def write(ctx, source_fn)
|
11
|
+
html_fn = File.join(File.dirname(source_fn), make_class_name(source_fn)) + '.html'
|
12
|
+
write_html html_fn unless File.exist? html_fn
|
13
|
+
write_skeleton source_fn unless File.exist? source_fn
|
14
|
+
write_source ctx, source_fn
|
15
|
+
end
|
16
|
+
|
17
|
+
def make_class_name(filename)
|
18
|
+
File.basename filename, '.*'
|
19
|
+
end
|
20
|
+
|
21
|
+
def write_html(html_fn)
|
22
|
+
class_name = make_class_name(html_fn)
|
23
|
+
File.open(html_fn, 'w') do |f|
|
24
|
+
writer = IndentedWriter.new f
|
25
|
+
writer.puts <<EOS
|
26
|
+
<!DOCTYPE html>
|
27
|
+
<html>
|
28
|
+
<head>
|
29
|
+
<meta charset="UTF-8" />
|
30
|
+
|
31
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/jasmine.js"></script>
|
32
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/jasmine-html.js"></script>
|
33
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/boot.js"></script>
|
34
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/jasmine.css" />
|
35
|
+
|
36
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine-ajax/3.2.0/mock-ajax.js"></script>
|
37
|
+
|
38
|
+
<script src="#{class_name}.js"></script>
|
39
|
+
</head>
|
40
|
+
<body>
|
41
|
+
</body>
|
42
|
+
</html>
|
43
|
+
EOS
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def write_skeleton(source_fn)
|
48
|
+
class_name = make_class_name(source_fn)
|
49
|
+
File.open(source_fn, 'w') do |f|
|
50
|
+
writer = IndentedWriter.new f
|
51
|
+
writer.puts <<EOS
|
52
|
+
describe('#{class_name}', function() {
|
53
|
+
|
54
|
+
beforeEach(function() {
|
55
|
+
this.testTarget = null; // TODO
|
56
|
+
});
|
57
|
+
|
58
|
+
afterEach(function() {
|
59
|
+
});
|
60
|
+
|
61
|
+
// %%
|
62
|
+
|
63
|
+
});
|
64
|
+
EOS
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def write_source(dsl_context, source_fn)
|
69
|
+
tmp_fn = source_fn + '.tmp'
|
70
|
+
source = File.open(source_fn).read
|
71
|
+
File.open(tmp_fn, 'w') do |f|
|
72
|
+
source.each_line do |line|
|
73
|
+
f.puts line
|
74
|
+
break if line =~ /^\s*\/\/\s*%%\s*$/
|
75
|
+
end
|
76
|
+
|
77
|
+
writer = IndentedWriter.new f
|
78
|
+
writer.blank
|
79
|
+
writer.block_indent ' ' do
|
80
|
+
writer.puts '//'
|
81
|
+
writer.puts '// 以下の行は自動生成されているので直接編集しないでください。'
|
82
|
+
writer.puts '//'
|
83
|
+
writer.puts '// Generated by Test Case Generator'
|
84
|
+
writer.puts '// https://rubygems.org/gems/test_case_generator'
|
85
|
+
writer.puts '//'
|
86
|
+
end
|
87
|
+
|
88
|
+
dsl_context.each do |pattern|
|
89
|
+
writer.block_indent ' ' do
|
90
|
+
writer.blank
|
91
|
+
writer.puts "it('#{pattern.join ', '}', function() {"
|
92
|
+
|
93
|
+
pattern.each do |ptn|
|
94
|
+
writer.block_indent ' ' do
|
95
|
+
writer.puts "#{ptn}(this);"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
writer.puts '});'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
writer.blank
|
104
|
+
writer.puts '});'
|
105
|
+
end
|
106
|
+
|
107
|
+
FileUtils.move tmp_fn, source_fn
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -8,13 +8,13 @@ module TestCaseGenerator
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def write(ctx, source_fn)
|
11
|
-
write_skeleton source_fn unless File.
|
11
|
+
write_skeleton source_fn unless File.exist? source_fn
|
12
12
|
write_header ctx, File.join(File.dirname(source_fn), File.basename(source_fn, File.extname(source_fn)) + 'Generated.h')
|
13
13
|
write_source ctx, source_fn
|
14
14
|
end
|
15
15
|
|
16
16
|
def make_class_name(filename)
|
17
|
-
File.basename filename,
|
17
|
+
File.basename filename, '.*'
|
18
18
|
end
|
19
19
|
|
20
20
|
def write_skeleton(source_fn)
|
@@ -8,12 +8,12 @@ module TestCaseGenerator
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def write(ctx, source_fn)
|
11
|
-
write_skeleton source_fn unless File.
|
11
|
+
write_skeleton source_fn unless File.exist? source_fn
|
12
12
|
write_source ctx, source_fn
|
13
13
|
end
|
14
14
|
|
15
15
|
def make_class_name(filename)
|
16
|
-
File.basename filename,
|
16
|
+
File.basename filename, '.*'
|
17
17
|
end
|
18
18
|
|
19
19
|
def write_skeleton(source_fn)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_case_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaoru Yanase
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -99,12 +99,14 @@ files:
|
|
99
99
|
- bin/setup
|
100
100
|
- bin/test_case_generator
|
101
101
|
- example/demo.testcase
|
102
|
+
- example/parallel.testcase
|
102
103
|
- exe/test_case_generator
|
103
104
|
- lib/test_case_generator.rb
|
104
105
|
- lib/test_case_generator/cli.rb
|
105
106
|
- lib/test_case_generator/dsl_context.rb
|
106
107
|
- lib/test_case_generator/generator_factory.rb
|
107
108
|
- lib/test_case_generator/generator_java.rb
|
109
|
+
- lib/test_case_generator/generator_javascript.rb
|
108
110
|
- lib/test_case_generator/generator_objective_c.rb
|
109
111
|
- lib/test_case_generator/generator_php.rb
|
110
112
|
- lib/test_case_generator/generator_python.rb
|