java-autotest 0.0.1.beta2 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/VERSION.yml +1 -1
- data/java-autotest.gemspec +9 -6
- data/lib/java_autotest/autotest.rb +7 -16
- data/lib/{file.rb → java_autotest/file.rb} +0 -0
- data/lib/java_autotest/test_runner.rb +9 -0
- data/lib/java_autotest.rb +3 -1
- data/spec/java_autotest/autotest_spec.rb +34 -8
- data/spec/java_autotest/file_spec.rb +19 -0
- data/spec/java_autotest/test_runner_spec.rb +16 -0
- metadata +14 -14
- data/spec/file_spec.rb +0 -18
data/README.rdoc
CHANGED
data/VERSION.yml
CHANGED
data/java-autotest.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{java-autotest}
|
8
|
-
s.version = "0.0.1
|
8
|
+
s.version = "0.0.1"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["rodolfoliviero"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-22}
|
13
13
|
s.default_executable = %q{java-autotest}
|
14
14
|
s.description = %q{Java AutoTest}
|
15
15
|
s.email = %q{rodolfoliviero@gmail.com}
|
@@ -29,11 +29,13 @@ Gem::Specification.new do |s|
|
|
29
29
|
"VERSION.yml",
|
30
30
|
"bin/java-autotest",
|
31
31
|
"java-autotest.gemspec",
|
32
|
-
"lib/file.rb",
|
33
32
|
"lib/java_autotest.rb",
|
34
33
|
"lib/java_autotest/autotest.rb",
|
35
|
-
"
|
34
|
+
"lib/java_autotest/file.rb",
|
35
|
+
"lib/java_autotest/test_runner.rb",
|
36
36
|
"spec/java_autotest/autotest_spec.rb",
|
37
|
+
"spec/java_autotest/file_spec.rb",
|
38
|
+
"spec/java_autotest/test_runner_spec.rb",
|
37
39
|
"spec/spec.opts",
|
38
40
|
"spec/spec_helper.rb",
|
39
41
|
"spec/src/main/java/Impl.java",
|
@@ -46,8 +48,9 @@ Gem::Specification.new do |s|
|
|
46
48
|
s.summary = %q{Java AutoTest}
|
47
49
|
s.test_files = [
|
48
50
|
"spec/spec_helper.rb",
|
51
|
+
"spec/java_autotest/test_runner_spec.rb",
|
49
52
|
"spec/java_autotest/autotest_spec.rb",
|
50
|
-
"spec/file_spec.rb"
|
53
|
+
"spec/java_autotest/file_spec.rb"
|
51
54
|
]
|
52
55
|
|
53
56
|
if s.respond_to? :specification_version then
|
@@ -1,15 +1,14 @@
|
|
1
1
|
class AutoTest
|
2
|
-
attr_accessor :
|
2
|
+
attr_accessor :run_at, :files
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
@
|
6
|
-
@files =
|
7
|
-
run_all_tests
|
5
|
+
@run_at = Time.new
|
6
|
+
@files = File.find_java_files
|
8
7
|
end
|
9
8
|
|
10
9
|
def listen
|
11
10
|
@files.each do |file|
|
12
|
-
if (File.atime(file).to_i > @
|
11
|
+
if (File.atime(file).to_i > @run_at.to_i)
|
13
12
|
run(file)
|
14
13
|
break
|
15
14
|
end
|
@@ -20,8 +19,8 @@ class AutoTest
|
|
20
19
|
def run(file)
|
21
20
|
test_class = find_test_class file
|
22
21
|
puts "Running test to #{test_class}."
|
23
|
-
green = run_test(test_class)
|
24
|
-
run_all_tests if green
|
22
|
+
green = TestRunner.run_test(test_class)
|
23
|
+
TestRunner.run_all_tests if green
|
25
24
|
reset
|
26
25
|
end
|
27
26
|
|
@@ -30,15 +29,7 @@ class AutoTest
|
|
30
29
|
return file.split("/").last if file.include? "Test.java"
|
31
30
|
end
|
32
31
|
|
33
|
-
def run_test(test_class)
|
34
|
-
system("mvn -Dtest=#{test_class} test")
|
35
|
-
end
|
36
|
-
|
37
|
-
def run_all_tests
|
38
|
-
system("mvn test")
|
39
|
-
end
|
40
|
-
|
41
32
|
def reset
|
42
|
-
@
|
33
|
+
@run_at = Time.new
|
43
34
|
end
|
44
35
|
end
|
File without changes
|
data/lib/java_autotest.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../lib/java_autotest/autotest'
|
2
|
-
require File.dirname(__FILE__) + '/../lib/file'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/java_autotest/file'
|
3
|
+
require File.dirname(__FILE__) + '/../lib/java_autotest/test_runner'
|
3
4
|
|
4
5
|
module JavaAutoTest
|
5
6
|
class Main
|
6
7
|
def self.execute
|
8
|
+
TestRunner.run_all_tests
|
7
9
|
autotest = AutoTest.new
|
8
10
|
loop do
|
9
11
|
begin
|
@@ -4,17 +4,43 @@ describe AutoTest do
|
|
4
4
|
|
5
5
|
before(:each) do
|
6
6
|
@autotest = AutoTest.new
|
7
|
+
@class = "src/main/java/app/model/Order.java"
|
7
8
|
end
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
|
10
|
+
context "run test" do
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
TestRunner.stub(:run_test).and_return false
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should reset run at date" do
|
17
|
+
now = mock(Time)
|
18
|
+
Time.stub!(:new).and_return(now)
|
19
|
+
@autotest.run(@class)
|
20
|
+
@autotest.run_at.should == now
|
21
|
+
end
|
22
|
+
|
23
|
+
it "cannot run all test if test fail" do
|
24
|
+
TestRunner.should_not_receive(:run_all_tests)
|
25
|
+
@autotest.run(@class)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should run all test if test pass" do
|
29
|
+
TestRunner.stub(:run_test).and_return true
|
30
|
+
TestRunner.should_receive(:run_all_tests)
|
31
|
+
@autotest.run(@class)
|
32
|
+
end
|
33
|
+
|
12
34
|
end
|
35
|
+
|
36
|
+
it "should find test class name when class is not a test class" do
|
37
|
+
test_class = @autotest.find_test_class(@class)
|
38
|
+
test_class.should == "OrderTest.java"
|
39
|
+
end
|
13
40
|
|
14
|
-
it "should
|
15
|
-
|
16
|
-
|
17
|
-
@autotest.run_test(test_class)
|
41
|
+
it "should find test class name when class is a test class" do
|
42
|
+
test_class = @autotest.find_test_class("src/test/java/app/model/OrderTest.java")
|
43
|
+
test_class.should == "OrderTest.java"
|
18
44
|
end
|
19
45
|
|
20
46
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe File do
|
4
|
+
|
5
|
+
context "find java files in source folder" do
|
6
|
+
before(:each) do
|
7
|
+
@files = File.find_java_files("spec/src")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should find impl file" do
|
11
|
+
@files[0].should == "spec/src/main/java/Impl.java"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should find test file" do
|
15
|
+
@files[1].should == "spec/src/test/java/ImplTest.java"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe TestRunner do
|
4
|
+
|
5
|
+
it "should run all tests" do
|
6
|
+
TestRunner.should_receive(:system).with("mvn test")
|
7
|
+
TestRunner.run_all_tests
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should run single test" do
|
11
|
+
test_class = "ImplTest.java"
|
12
|
+
TestRunner.should_receive(:system).with("mvn -Dtest=#{test_class} test")
|
13
|
+
TestRunner.run_test(test_class)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: java-autotest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- 1
|
10
|
-
|
11
|
-
version: 0.0.1.beta2
|
10
|
+
version: 0.0.1
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- rodolfoliviero
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-22 00:00:00 -03:00
|
20
19
|
default_executable: java-autotest
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
@@ -55,11 +54,13 @@ files:
|
|
55
54
|
- VERSION.yml
|
56
55
|
- bin/java-autotest
|
57
56
|
- java-autotest.gemspec
|
58
|
-
- lib/file.rb
|
59
57
|
- lib/java_autotest.rb
|
60
58
|
- lib/java_autotest/autotest.rb
|
61
|
-
-
|
59
|
+
- lib/java_autotest/file.rb
|
60
|
+
- lib/java_autotest/test_runner.rb
|
62
61
|
- spec/java_autotest/autotest_spec.rb
|
62
|
+
- spec/java_autotest/file_spec.rb
|
63
|
+
- spec/java_autotest/test_runner_spec.rb
|
63
64
|
- spec/spec.opts
|
64
65
|
- spec/spec_helper.rb
|
65
66
|
- spec/src/main/java/Impl.java
|
@@ -85,14 +86,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
87
|
none: false
|
87
88
|
requirements:
|
88
|
-
- - "
|
89
|
+
- - ">="
|
89
90
|
- !ruby/object:Gem::Version
|
90
|
-
hash:
|
91
|
+
hash: 3
|
91
92
|
segments:
|
92
|
-
-
|
93
|
-
|
94
|
-
- 1
|
95
|
-
version: 1.3.1
|
93
|
+
- 0
|
94
|
+
version: "0"
|
96
95
|
requirements: []
|
97
96
|
|
98
97
|
rubyforge_project:
|
@@ -102,5 +101,6 @@ specification_version: 3
|
|
102
101
|
summary: Java AutoTest
|
103
102
|
test_files:
|
104
103
|
- spec/spec_helper.rb
|
104
|
+
- spec/java_autotest/test_runner_spec.rb
|
105
105
|
- spec/java_autotest/autotest_spec.rb
|
106
|
-
- spec/file_spec.rb
|
106
|
+
- spec/java_autotest/file_spec.rb
|
data/spec/file_spec.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
|
2
|
-
|
3
|
-
describe File do
|
4
|
-
|
5
|
-
context "find java files in source folder" do
|
6
|
-
before(:each) do
|
7
|
-
@files = File.find_java_files("spec/src")
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should find impl file" do
|
11
|
-
@files[0].should == "spec/src/main/java/Impl.java"
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should find test file" do
|
15
|
-
@files[1].should == "spec/src/test/java/ImplTest.java"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|