DTR 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,91 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- class OriginalTestReportsTest < Test::Unit::TestCase
4
-
5
- def setup
6
- @reports = DTR::OriginalTestReports.new
7
- end
8
-
9
- def test_summary_of_report
10
- assert_equal '.', @reports.summary_of(create_report(1, 1, 0, 0))
11
- assert_equal '...', @reports.summary_of(create_report(3, 3, 0, 0))
12
- assert_equal 'F', @reports.summary_of(create_report(1, 10, 1, 0))
13
- assert_equal 'E', @reports.summary_of(create_report(1, 15, 0, 1))
14
- assert_equal '.FFE', @reports.summary_of(create_report(4, 10, 2, 1))
15
- end
16
-
17
- def test_failures_and_errors
18
- expected = %{ 1) Failure:
19
- test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
20
- <false> is not true.
21
- }
22
- @reports.summary_of(create_a_failed_report)
23
- assert_equal(expected, @reports.failures_and_errors)
24
-
25
- expected = %{ 1) Failure:
26
- test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
27
- <false> is not true.
28
-
29
- 2) Failure:
30
- test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
31
- <false> is not true.
32
- }
33
- @reports.summary_of(create_a_failed_report)
34
- assert_equal(expected, @reports.failures_and_errors)
35
-
36
- expected = %{ 1) Error:
37
- test_error(AnErrorTestCase):
38
- RuntimeError: error
39
- an_error_test_case.rb:4:in `test_error'
40
-
41
- 2) Failure:
42
- test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
43
- <false> is not true.
44
-
45
- 3) Failure:
46
- test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
47
- <false> is not true.
48
- }
49
- @reports.summary_of(create_an_error_report)
50
- assert_equal(expected, @reports.failures_and_errors)
51
- end
52
-
53
- def create_report(*test_summary)
54
- DTR::TestReport.new('test_file_name', {:name => 'client name', :exit_code => 0}, *test_summary)
55
- end
56
-
57
- def create_a_failed_report
58
- stdout = %{
59
- thought-workers-computer:~/dtr/testdata thoughtworker$ ruby a_failed_test_case.rb
60
- Loaded suite a_failed_test_case
61
- Started
62
- F
63
- Finished in 0.014801 seconds.
64
-
65
- 1) Failure:
66
- test_failed(AFailedTestCase) [a_failed_test_case.rb:4]:
67
- <false> is not true.
68
-
69
- 1 tests, 1 assertions, 1 failures, 0 errors
70
- }
71
- DTR::TestReport.new('a_failed_test_case.rb', {:name => 'client name', :exit_code => 0, :stdout => stdout}, 1, 1, 1, 0)
72
- end
73
-
74
- def create_an_error_report
75
- stdout = %{
76
- thought-workers-computer:~/dtr/testdata thoughtworker$ ruby an_error_test_case.rb
77
- Loaded suite an_error_test_case
78
- Started
79
- E
80
- Finished in 0.000483 seconds.
81
-
82
- 1) Error:
83
- test_error(AnErrorTestCase):
84
- RuntimeError: error
85
- an_error_test_case.rb:4:in `test_error'
86
-
87
- 1 tests, 0 assertions, 0 failures, 1 errors
88
- }
89
- DTR::TestReport.new('an_error_test_case.rb', {:name => 'client name', :exit_code => 0, :stdout => stdout}, 1, 1, 0, 1)
90
- end
91
- end
@@ -1,13 +0,0 @@
1
- require 'test/unit'
2
- require File.dirname(__FILE__) + '/test_helper'
3
-
4
- class RubyExtTest < Test::Unit::TestCase
5
- def test_array_to_acl_list
6
- assert_equal %w(allow localhost allow 127.0.0.1), [].to_acl_list
7
- assert_equal %w(allow localhost allow 127.0.0.1).sort, ['druby://localhost:8888', 'sldjf'].to_acl_list.sort
8
- assert_equal %w(allow localhost allow 127.0.0.1).sort, ['druby://127.0.0.1'].to_acl_list.sort
9
- assert_equal %w(allow localhost allow 127.0.0.1 allow 192.168.0.111).sort, ['druby://192.168.0.111:3344'].to_acl_list.sort
10
- assert_equal %w(allow localhost allow 127.0.0.1 allow 192.168.0.111 allow 182.1.1.1).sort, ['druby://192.168.0.111:3344', 'druby://182.1.1.1'].to_acl_list.sort
11
- end
12
- end
13
-
@@ -1,56 +0,0 @@
1
- require 'test/unit'
2
- require File.dirname(__FILE__) + '/test_helper'
3
-
4
- class RubyRunnerTest < Test::Unit::TestCase
5
-
6
- def setup
7
- @report = nil
8
- @executed_cmd = nil
9
- @executed_time = 0
10
- @report_updated = true
11
- @test_case_1 = File.dirname(__FILE__) + '/../testdata/a_test_case.rb'
12
- @runner = DTR::RubyRunner.new
13
- end
14
-
15
- def test_should_not_run_test_file_not_exists
16
- @runner.run self, self, ['test_file_not_exists.rb'], 'signature'
17
- assert_nil @executed_cmd
18
- assert_nil @report
19
- end
20
-
21
- def test_should_not_continue_to_run_tests_after_updated_report_failed
22
- @report_updated = false
23
- @runner.run self, self, [@test_case_1, File.dirname(__FILE__) + '/../testdata/a_test_case2.rb'], 'signature'
24
- assert_equal 1, @executed_time
25
- end
26
-
27
- def test_should_not_run_test_file_if_server_has_its_report
28
- reports[@test_case_1] = 'report'
29
- @runner.run self, self, [@test_case_1], 'signature'
30
- assert_equal 0, @executed_time
31
- assert_nil @report
32
- end
33
-
34
- def test_parse_stdout
35
- assert_equal [2, 5, 1, 1], @runner.parse(%{
36
- 1 tests, 1 assertions, 0 failures, 0 errors
37
- 2 tests, 5 assertions, 1 failures, 1 errors
38
- [[TestCase finished]]
39
- })
40
- end
41
-
42
- def update(signature, report)
43
- @report = report
44
- @report_updated
45
- end
46
-
47
- def reports
48
- @reports ||= {}
49
- end
50
-
51
- def execute(cmd)
52
- @executed_time += 1
53
- @executed_cmd = cmd
54
- {:client_name => 'client name', :stdout => %{Finished in 1.1 seconds. \n4 tests, 2 assertions, 1 failures, 2 errors}, :stderr => 'outputs[:stderr]', :exit_code => 0}
55
- end
56
- end
@@ -1,51 +0,0 @@
1
- # -*- coding: UTF-8 -*-
2
-
3
- require 'test/unit'
4
-
5
- #require 'logger'
6
- #def logger
7
- # logger = Logger.new STDOUT
8
- # logger.level = Logger::DEBUG
9
- # logger
10
- #end
11
-
12
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
13
- require 'dtr'
14
-
15
- Thread.new do
16
- Dir.chdir(File.dirname(__FILE__) + '/../testdata') do
17
- DTROPTIONS[:setup] = 'rake setup'
18
- DTR.start_client_server
19
- end
20
- end.join(1)
21
-
22
- DTROPTIONS[:wait_a_moment] = false
23
-
24
- class ScenarioSetupAndRunTestsSimply < Test::Unit::TestCase
25
-
26
- def test_run_success
27
- assert DTR.run(['a_test_case.rb', 'a_test_case2.rb'], ['druby://localhost:3344'])
28
- end
29
-
30
- def test_run_failed
31
- assert !DTR.run(['a_test_case.rb', 'an_error_test_case.rb', 'a_test_case2.rb'], ['druby://localhost:3344'])
32
- end
33
-
34
- def test_run_setup_and_tests
35
- assert DTR.run(['test_case_created_by_setup.rb'], ['druby://localhost:3344'], :run_setup_before_start => true)
36
- ensure
37
- File.delete 'test_case_created_by_setup.rb' if File.exist?('test_case_created_by_setup.rb')
38
- end
39
-
40
- def test_should_crash_when_there_is_client_cant_be_connected
41
- assert DTR.run(['a_test_case.rb', 'a_test_case2.rb'], ['druby://localhost:5555', 'druby://localhost:3344'])
42
- end
43
-
44
- def test_should_failed_when_turn_on_option_and_there_is_no_client_alive
45
- DTROPTIONS[:raise_on_no_alive_client] = true
46
- assert !DTR.run(['a_test_case.rb'], ['druby://localhost:2345'])
47
- end
48
- end
49
-
50
-
51
-
data/test/server_test.rb DELETED
@@ -1,39 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- class ServerTest < Test::Unit::TestCase
4
- def setup
5
- @server = DTR::Server.new
6
- end
7
-
8
- def test_available_clients_should_not_contain_clients_not_idle
9
- @server.add_client client_idling
10
- @server.add_client client_not_idling
11
-
12
- assert_equal [client_idling], @server.available_clients
13
- end
14
-
15
- def test_available_clients_should_contain_clients_connecting_self
16
- client_connecting = OpenStruct.new :idle? => true, :server_signature => @server.server_signature, :name => 'client 1'
17
- client_not_connecting = OpenStruct.new :idle? => true, :server_signature => DTR::Server.new.server_signature, :name => 'client 2'
18
- @server.add_client client_connecting
19
- @server.add_client client_not_connecting
20
-
21
- assert_equal [client_connecting], @server.available_clients
22
- end
23
-
24
- def test_should_reset_client_setup_log_when_add_client
25
- @server.add_client client_idling
26
- @server.client_setup_logs[client_idling.name] = 'report'
27
- @server.add_client client_idling
28
- assert_nil @server.client_setup_logs[client_idling.name]
29
- end
30
-
31
- def client_idling
32
- OpenStruct.new :idle? => true, :server_signature => @server.server_signature, :name => 'client idling'
33
- end
34
-
35
- def client_not_idling
36
- OpenStruct.new :idle? => false, :server_signature => @server.server_signature, :name => 'client not idling'
37
- end
38
- end
39
-