rwebunit 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/Rakefile +2 -3
- data/lib/rwebunit/test_context.rb +10 -10
- data/lib/rwebunit/test_utils.rb +73 -73
- data/lib/rwebunit/web_page.rb +78 -54
- data/lib/rwebunit/web_testcase.rb +203 -204
- data/lib/rwebunit/web_tester.rb +398 -381
- data/lib/rwebunit.rb +0 -2
- data/sample/kangxi_home_webtest.rb +9 -9
- data/sample/kangxi_httpcaller_webtest.rb +4 -4
- data/sample/kangxi_xml_formatter_webtest.rb +9 -9
- data/sample/sample_rwebunit_test.rb +1 -1
- data/sample/sample_rwebunit_testcase.rb +1 -1
- data/sample/sample_watir_test.rb +12 -12
- data/test/test_test_utils.rb +58 -58
- metadata +10 -9
data/lib/rwebunit.rb
CHANGED
@@ -5,9 +5,9 @@ require "rwebunit"
|
|
5
5
|
$:.unshift File.dirname(__FILE__)
|
6
6
|
require "kangxi_pages.rb"
|
7
7
|
|
8
|
-
class
|
8
|
+
class TestKangxiHome < RWebUnit::WebTestCase
|
9
9
|
|
10
|
-
def initialize(name)
|
10
|
+
def initialize(name)
|
11
11
|
super(name)
|
12
12
|
end
|
13
13
|
|
@@ -23,15 +23,15 @@ class TestWuning < RWebUnit::WebTestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_homepage_exists()
|
26
|
-
|
26
|
+
kangxi_homepage = KangxiHomePage.new(@web_tester, "Welcome")
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_all_links_exist
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
kangxi_homepage = KangxiHomePage.new(@web_tester, "Welcome")
|
31
|
+
kangxi_homepage.assertTheListLinkPresent()
|
32
|
+
kangxi_homepage.assertDashboardLinkPresent
|
33
|
+
kangxi_homepage.assertTestCenterLinkPresent
|
34
|
+
kangxi_homepage.assertTestWebServiceLinkPresent
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
end
|
@@ -7,7 +7,7 @@ require "kangxi_pages.rb"
|
|
7
7
|
|
8
8
|
class TestHttpCaller < RWebUnit::WebTestCase
|
9
9
|
|
10
|
-
def initialize(name)
|
10
|
+
def initialize(name)
|
11
11
|
super(name)
|
12
12
|
end
|
13
13
|
|
@@ -23,9 +23,9 @@ class TestHttpCaller < RWebUnit::WebTestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_can_display()
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
kangxi_httpcaller_page = KangxiHttpCallerPage.new(@web_tester)
|
27
|
+
@web_tester.assertOptionValuePresent("method", "POST")
|
28
|
+
@web_tester.assertOptionValuePresent("method", "GET")
|
29
29
|
|
30
30
|
end
|
31
31
|
|
@@ -7,7 +7,7 @@ require "kangxi_pages.rb"
|
|
7
7
|
|
8
8
|
class TestXmlFormatter < RWebUnit::WebTestCase
|
9
9
|
|
10
|
-
def initialize(name)
|
10
|
+
def initialize(name)
|
11
11
|
super(name)
|
12
12
|
end
|
13
13
|
|
@@ -25,20 +25,20 @@ class TestXmlFormatter < RWebUnit::WebTestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_can_invoke_format
|
28
|
-
|
29
|
-
|
28
|
+
@kangxi_xmlformatter_page.enterXml("<name><first>James</first><last>Bond</last></name>")
|
29
|
+
@kangxi_xmlformatter_page.clickFormat
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_format_sample_xml
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
@kangxi_xmlformatter_page.clickFillExampleLink
|
34
|
+
@web_tester.assertElementNotPresent("formatted_xml")
|
35
|
+
@kangxi_xmlformatter_page.submit
|
36
|
+
@web_tester.assertElementPresent("formatted_xml")
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_can_call_utils
|
40
|
-
|
41
|
-
|
40
|
+
@kangxi_xmlformatter_page.enterXml("<date><now>" + getToday + "</now></date>")
|
41
|
+
@kangxi_xmlformatter_page.clickFormat
|
42
42
|
end
|
43
43
|
|
44
44
|
end
|
data/sample/sample_watir_test.rb
CHANGED
@@ -3,15 +3,15 @@ require 'watir'
|
|
3
3
|
require 'test/unit'
|
4
4
|
|
5
5
|
class WatirSearchExample < Test::Unit::TestCase
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
6
|
+
|
7
|
+
def test_search
|
8
|
+
ie = Watir::IE.new
|
9
|
+
ie.goto("http://www.google.com")
|
10
|
+
ie.text_field(:name, "q").set("httpunit")
|
11
|
+
ie.button(:name, "btnG").click
|
12
|
+
ie.link(:text, "HttpUnit Home").click
|
13
|
+
assert_equal("HttpUnit Home", ie.document.title)
|
14
|
+
assert(ie.contains_text("User's Manual"))
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/test/test_test_utils.rb
CHANGED
@@ -5,69 +5,69 @@ require "test_utils.rb"
|
|
5
5
|
require 'test/unit'
|
6
6
|
|
7
7
|
class TestWebTestCase < Test::Unit::TestCase
|
8
|
-
|
8
|
+
include RWebUnit::Utils
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
def setup
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
def teardown
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
def test_getToday
|
17
|
+
today_str = sprintf("%02d/%02d/%04d", Time.now.day, Time.now.month, Time.now.year)
|
18
|
+
assert_equal(today_str, getToday)
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
def test_getDaysAfter
|
29
|
-
tomorrow = Time.now + 24 * 3600 * 1
|
30
|
-
tomorrow_str = sprintf("%02d/%02d/%04d", tomorrow.day, tomorrow.month, tomorrow.year)
|
31
|
-
assert_equal(tomorrow_str, getDaysAfter(1))
|
32
|
-
assert_equal(tomorrow_str, getTomorrow)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_randomBoolean
|
36
|
-
true_count = 0
|
37
|
-
false_count = 0
|
38
|
-
100.times {
|
39
|
-
obj = randomBoolean
|
40
|
-
assert(obj.instance_of?(TrueClass) || obj.instance_of?(FalseClass), "can only be true or false")
|
41
|
-
true_count += 1 if obj
|
42
|
-
false_count += 1 if !obj
|
43
|
-
}
|
44
|
-
assert(true_count > 0, "it is not random")
|
45
|
-
assert(false_count > 0, "it is not random")
|
46
|
-
end
|
21
|
+
def test_getDaysBefore
|
22
|
+
yesterday = Time.now - 24 * 3600 * 1
|
23
|
+
yesterday_str = sprintf("%02d/%02d/%04d", yesterday.day, yesterday.month, yesterday.year)
|
24
|
+
assert_equal(yesterday_str, getDaysBefore(1))
|
25
|
+
assert_equal(yesterday_str, getYesterday)
|
26
|
+
end
|
47
27
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
55
|
-
uniq_numbers = tmp_array.uniq.sort
|
56
|
-
assert_equal(10, uniq_numbers.length)
|
57
|
-
assert_equal(1, uniq_numbers[0])
|
58
|
-
assert_equal(10, uniq_numbers[9])
|
59
|
-
end
|
28
|
+
def test_getDaysAfter
|
29
|
+
tomorrow = Time.now + 24 * 3600 * 1
|
30
|
+
tomorrow_str = sprintf("%02d/%02d/%04d", tomorrow.day, tomorrow.month, tomorrow.year)
|
31
|
+
assert_equal(tomorrow_str, getDaysAfter(1))
|
32
|
+
assert_equal(tomorrow_str, getTomorrow)
|
33
|
+
end
|
60
34
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
35
|
+
def test_randomBoolean
|
36
|
+
true_count = 0
|
37
|
+
false_count = 0
|
38
|
+
100.times {
|
39
|
+
obj = randomBoolean
|
40
|
+
assert(obj.instance_of?(TrueClass) || obj.instance_of?(FalseClass), "can only be true or false")
|
41
|
+
true_count += 1 if obj
|
42
|
+
false_count += 1 if !obj
|
43
|
+
}
|
44
|
+
assert(true_count > 0, "it is not random")
|
45
|
+
assert(false_count > 0, "it is not random")
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_randomNumber
|
49
|
+
tmp_array = []
|
50
|
+
1000.times {
|
51
|
+
num = randomNumber(1,10)
|
52
|
+
assert(num.instance_of?(Fixnum), "can only be number")
|
53
|
+
tmp_array << num
|
54
|
+
}
|
55
|
+
uniq_numbers = tmp_array.uniq.sort
|
56
|
+
assert_equal(10, uniq_numbers.length)
|
57
|
+
assert_equal(1, uniq_numbers[0])
|
58
|
+
assert_equal(10, uniq_numbers[9])
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_randomDigit
|
62
|
+
tmp_array = []
|
63
|
+
1000.times {
|
64
|
+
dc = randomDigit()
|
65
|
+
tmp_array << dc
|
66
|
+
}
|
67
|
+
uniq_digits = tmp_array.uniq.sort
|
68
|
+
assert_equal(10, uniq_digits.length)
|
69
|
+
assert_equal('0', uniq_digits[0])
|
70
|
+
assert_equal('9', uniq_digits[9])
|
71
|
+
end
|
72
72
|
|
73
73
|
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: rwebunit
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2006-11-28 00:00:00 +10:00
|
8
8
|
summary: An wrap of WATIR for functional testing of web applications
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- Zhimin Zhan
|
30
31
|
files:
|
@@ -32,23 +33,23 @@ files:
|
|
32
33
|
- README
|
33
34
|
- CHANGELOG
|
34
35
|
- MIT-LICENSE
|
35
|
-
- lib/rwebunit.rb
|
36
36
|
- lib/rwebunit
|
37
|
+
- lib/rwebunit.rb
|
37
38
|
- lib/rwebunit/test_context.rb
|
38
39
|
- lib/rwebunit/test_utils.rb
|
39
40
|
- lib/rwebunit/web_page.rb
|
40
41
|
- lib/rwebunit/web_testcase.rb
|
41
42
|
- lib/rwebunit/web_tester.rb
|
42
43
|
- test/test_test_utils.rb
|
43
|
-
- sample/kangxi_pages.rb
|
44
|
-
- sample/sample_rwebunit_test.rb
|
45
|
-
- sample/sample_rwebunit_testcase.rb
|
46
|
-
- sample/sample_watir_test.rb
|
47
|
-
- sample/README.txt
|
48
44
|
- sample/kangxi_home_webtest.rb
|
49
45
|
- sample/kangxi_httpcaller_webtest.rb
|
46
|
+
- sample/kangxi_pages.rb
|
50
47
|
- sample/kangxi_xml_formatter_webtest.rb
|
48
|
+
- sample/README.txt
|
51
49
|
- sample/rwebunit_home_testcase.rb
|
50
|
+
- sample/sample_rwebunit_test.rb
|
51
|
+
- sample/sample_rwebunit_testcase.rb
|
52
|
+
- sample/sample_watir_test.rb
|
52
53
|
- docs/html
|
53
54
|
- docs/html/index.html
|
54
55
|
test_files: []
|