Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 116 lines (101 sloc) 4.952 kb
6da80dc @nicksieger Add start of acceptance tests
nicksieger authored
1 require 'rexml/document'
2
930f7d6 @nicksieger Add three acceptance tests for Test::Unit, and one TODO for RSpec
nicksieger authored
3 REPORTS_DIR = File.dirname(__FILE__) + '/reports'
4
6da80dc @nicksieger Add start of acceptance tests
nicksieger authored
5 describe "Test::Unit acceptance" do
6 it "should generate two XML files" do
930f7d6 @nicksieger Add three acceptance tests for Test::Unit, and one TODO for RSpec
nicksieger authored
7 File.exist?(File.join(REPORTS_DIR, 'TEST-TestUnitExampleTestOne.xml')).should == true
8 File.exist?(File.join(REPORTS_DIR, 'TEST-TestUnitExampleTestTwo.xml')).should == true
9 end
10
11 it "should have one error and one failure for TestUnitExampleTestOne" do
12 doc = File.open(File.join(REPORTS_DIR, 'TEST-TestUnitExampleTestOne.xml')) do |f|
13 REXML::Document.new(f)
14 end
15 doc.root.attributes["errors"].should == "1"
16 doc.root.attributes["failures"].should == "1"
17 doc.root.attributes["assertions"].should == "1"
18 doc.root.attributes["tests"].should == "1"
7e50b59 @nicksieger Finished acceptance tests
nicksieger authored
19 doc.root.elements.to_a("/testsuite/testcase").size.should == 1
20 doc.root.elements.to_a("/testsuite/testcase/failure").size.should == 2
a5d3b65 @nicksieger GH #1: Fix output in system-out/system-err
nicksieger authored
21 doc.root.elements.to_a("/testsuite/system-out").first.texts.inject("") do |c,e|
22 c << e.value; c
23 end.strip.should == "Some <![CDATA[on stdout]]>"
930f7d6 @nicksieger Add three acceptance tests for Test::Unit, and one TODO for RSpec
nicksieger authored
24 end
25
26 it "should have no errors or failures for TestUnitExampleTestTwo" do
27 doc = File.open(File.join(REPORTS_DIR, 'TEST-TestUnitExampleTestTwo.xml')) do |f|
28 REXML::Document.new(f)
29 end
30 doc.root.attributes["errors"].should == "0"
31 doc.root.attributes["failures"].should == "0"
32 doc.root.attributes["assertions"].should == "1"
33 doc.root.attributes["tests"].should == "1"
7e50b59 @nicksieger Finished acceptance tests
nicksieger authored
34 doc.root.elements.to_a("/testsuite/testcase").size.should == 1
35 doc.root.elements.to_a("/testsuite/testcase/failure").size.should == 0
930f7d6 @nicksieger Add three acceptance tests for Test::Unit, and one TODO for RSpec
nicksieger authored
36 end
37 end
38
39 describe "RSpec acceptance" do
28d371d @nicksieger Tagging 1.5.1
nicksieger authored
40 it "should generate two XML files" do
7e50b59 @nicksieger Finished acceptance tests
nicksieger authored
41 File.exist?(File.join(REPORTS_DIR, 'SPEC-RSpec-example.xml')).should == true
28d371d @nicksieger Tagging 1.5.1
nicksieger authored
42 File.exist?(File.join(REPORTS_DIR, 'SPEC-RSpec-example-nested.xml')).should == true
7e50b59 @nicksieger Finished acceptance tests
nicksieger authored
43 end
44
45 it "should have two tests and one failure" do
46 doc = File.open(File.join(REPORTS_DIR, 'SPEC-RSpec-example.xml')) do |f|
47 REXML::Document.new(f)
48 end
49 doc.root.attributes["errors"].should == "0"
50 doc.root.attributes["failures"].should == "1"
28d371d @nicksieger Tagging 1.5.1
nicksieger authored
51 doc.root.attributes["tests"].should == "3"
52 doc.root.elements.to_a("/testsuite/testcase").size.should == 3
7e50b59 @nicksieger Finished acceptance tests
nicksieger authored
53 failures = doc.root.elements.to_a("/testsuite/testcase/failure")
54 failures.size.should == 1
55 failures.first.attributes["type"].should == "Spec::Expectations::ExpectationNotMetError"
6da80dc @nicksieger Add start of acceptance tests
nicksieger authored
56 end
28d371d @nicksieger Tagging 1.5.1
nicksieger authored
57
58 it "should have one test in the nested example report" do
59 doc = File.open(File.join(REPORTS_DIR, 'SPEC-RSpec-example-nested.xml')) do |f|
60 REXML::Document.new(f)
61 end
62 doc.root.attributes["errors"].should == "0"
63 doc.root.attributes["failures"].should == "0"
64 doc.root.attributes["tests"].should == "1"
65 doc.root.elements.to_a("/testsuite/testcase").size.should == 1
66 end
7e50b59 @nicksieger Finished acceptance tests
nicksieger authored
67 end
ebfd936 @mathie Acceptance tests for cucumber integration.
mathie authored
68
69 describe "Cucumber acceptance" do
8df0657 @mathie Accept (and demonstrate) that Cucumber doesn't differentiate between fai...
mathie authored
70 it "should generate three XML files" do
b5e57b6 @mathie Set the prefix to be features, rather than cucumber.
mathie authored
71 File.exist?(File.join(REPORTS_DIR, 'FEATURES-Feature-Example-feature-Conscientious-developer.xml')).should == true
72 File.exist?(File.join(REPORTS_DIR, 'FEATURES-Feature-Example-feature-Lazy-hacker.xml')).should == true
73 File.exist?(File.join(REPORTS_DIR, 'FEATURES-Feature-Example-feature-Bad-coder.xml')).should == true
8df0657 @mathie Accept (and demonstrate) that Cucumber doesn't differentiate between fai...
mathie authored
74
b5e57b6 @mathie Set the prefix to be features, rather than cucumber.
mathie authored
75 Dir["#{REPORTS_DIR}/FEATURES-*.xml"].length.should == 3
ebfd936 @mathie Acceptance tests for cucumber integration.
mathie authored
76 end
77
78 it "should have three tests and no failures for the conscientious developer" do
b5e57b6 @mathie Set the prefix to be features, rather than cucumber.
mathie authored
79 doc = File.open(File.join(REPORTS_DIR, 'FEATURES-Feature-Example-feature-Conscientious-developer.xml')) do |f|
ebfd936 @mathie Acceptance tests for cucumber integration.
mathie authored
80 REXML::Document.new(f)
81 end
82 doc.root.attributes["errors"].should == "0"
83 doc.root.attributes["failures"].should == "0"
84 doc.root.attributes["tests"].should == "3"
85 doc.root.elements.to_a("/testsuite/testcase").size.should == 3
86 end
87
8c67cdd @mathie Pending steps should not be reported as errors.
mathie authored
88 it "should have three tests and one failure for the lazy hacker" do
b5e57b6 @mathie Set the prefix to be features, rather than cucumber.
mathie authored
89 doc = File.open(File.join(REPORTS_DIR, 'FEATURES-Feature-Example-feature-Lazy-hacker.xml')) do |f|
ebfd936 @mathie Acceptance tests for cucumber integration.
mathie authored
90 REXML::Document.new(f)
91 end
8c67cdd @mathie Pending steps should not be reported as errors.
mathie authored
92 doc.root.attributes["errors"].should == "0"
ebfd936 @mathie Acceptance tests for cucumber integration.
mathie authored
93 doc.root.attributes["failures"].should == "1"
94 doc.root.attributes["tests"].should == "3"
95 doc.root.elements.to_a("/testsuite/testcase").size.should == 3
96
97 failures = doc.root.elements.to_a("/testsuite/testcase/failure")
98 failures.size.should == 1
99 failures.first.attributes["type"].should == "Spec::Expectations::ExpectationNotMetError"
100 end
8df0657 @mathie Accept (and demonstrate) that Cucumber doesn't differentiate between fai...
mathie authored
101
102 it "should have three tests and one failure for the bad coder" do
b5e57b6 @mathie Set the prefix to be features, rather than cucumber.
mathie authored
103 doc = File.open(File.join(REPORTS_DIR, 'FEATURES-Feature-Example-feature-Bad-coder.xml')) do |f|
8df0657 @mathie Accept (and demonstrate) that Cucumber doesn't differentiate between fai...
mathie authored
104 REXML::Document.new(f)
105 end
106 doc.root.attributes["errors"].should == "0"
107 doc.root.attributes["failures"].should == "1"
108 doc.root.attributes["tests"].should == "3"
109 doc.root.elements.to_a("/testsuite/testcase").size.should == 3
110
111 failures = doc.root.elements.to_a("/testsuite/testcase/failure")
112 failures.size.should == 1
113 failures.first.attributes["type"].should == "RuntimeError"
114 end
ebfd936 @mathie Acceptance tests for cucumber integration.
mathie authored
115 end
Something went wrong with that request. Please try again.