Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Our first cucumber-features scenario is passing.
- Loading branch information
1 parent
0305720
commit 6762f16
Showing
14 changed files
with
195 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
target | ||
*.ipr | ||
*.iws | ||
tmp/ | ||
doc/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "cucumber-features"] | ||
path = cucumber-features | ||
url = git://github.com/cucumber/cucumber-features.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rvm @cucumber --create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'http://rubygems.org' | ||
|
||
gem 'cucumber', '1.0.0' | ||
gem 'aruba', '0.4.3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
aruba (0.4.3) | ||
bcat (>= 0.6.1) | ||
childprocess (>= 0.1.9) | ||
cucumber (>= 0.10.7) | ||
rdiscount (>= 1.6.8) | ||
rspec (>= 2.6.0) | ||
bcat (0.6.1) | ||
rack (~> 1.0) | ||
builder (3.0.0) | ||
childprocess (0.1.9) | ||
ffi (~> 1.0.6) | ||
cucumber (1.0.0) | ||
builder (>= 2.1.2) | ||
diff-lcs (>= 1.1.2) | ||
gherkin (~> 2.4.1) | ||
json (>= 1.4.6) | ||
term-ansicolor (>= 1.0.5) | ||
diff-lcs (1.1.2) | ||
ffi (1.0.9) | ||
gherkin (2.4.1) | ||
json (>= 1.4.6) | ||
json (1.5.3) | ||
rack (1.3.0) | ||
rdiscount (1.6.8) | ||
rspec (2.6.0) | ||
rspec-core (~> 2.6.0) | ||
rspec-expectations (~> 2.6.0) | ||
rspec-mocks (~> 2.6.0) | ||
rspec-core (2.6.4) | ||
rspec-expectations (2.6.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.6.0) | ||
term-ansicolor (1.0.5) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
aruba (= 0.4.3) | ||
cucumber (= 1.0.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'cucumber/rake/task' | ||
|
||
Cucumber::Rake::Task.new(:picocontainer) do |t| | ||
t.cucumber_opts = '-r java/src/test/resources/cucumber-features -r cucumber-features cucumber-features' | ||
end | ||
|
||
task :default => :picocontainer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package cucumber.junit; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE}) | ||
public @interface Feature { | ||
String value(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule cucumber-features
added at
5dcb56
104 changes: 104 additions & 0 deletions
104
java/src/test/resources/cucumber-features/cucumber_java_mappings.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
require 'erb' | ||
|
||
module CucumberJavaMappings | ||
def features_dir | ||
"src/test/resources" | ||
end | ||
|
||
def run_scenario(scenario_name) | ||
write_pom | ||
write_test_unit_classes | ||
run_simple "mvn test", false | ||
end | ||
|
||
def write_pom | ||
write_file('pom.xml', <<-EOF) | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | ||
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>cucumber</groupId> | ||
<artifactId>parent</artifactId> | ||
<relativePath>../../pom.xml</relativePath> | ||
<version>0.4.3-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>cucumber-picocontainer-test</artifactId> | ||
<version>0.4.3-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<name>Cucumber: PicoContainer Test</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>cucumber</groupId> | ||
<artifactId>picocontainer</artifactId> | ||
<version>0.4.3-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
</project> | ||
EOF | ||
end | ||
|
||
@@mappings_counter = 1 | ||
|
||
def write_passing_mapping(step_name) | ||
erb = ERB.new(<<-EOF, nil, '-') | ||
package cucumber.test; | ||
import cucumber.annotation.EN.Given; | ||
public class Mappings<%= @@mappings_counter %> { | ||
@Given("<%= step_name -%>") | ||
public void <%= step_name.gsub(/ /, '_') -%>() { | ||
// ARUBA_IGNORE_START | ||
try { | ||
new java.io.FileWriter("<%= step_file(step_name) %>"); | ||
} catch(java.io.IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
// ARUBA_IGNORE_END | ||
} | ||
} | ||
EOF | ||
write_file("src/test/java/cucumber/test/Mappings#{@@mappings_counter}.java", erb.result(binding)) | ||
@@mappings_counter += 1 | ||
end | ||
|
||
def write_test_unit_classes | ||
features = in_current_dir do | ||
Dir.chdir(features_dir) do | ||
Dir["**/*.feature"] | ||
end | ||
end | ||
features.each do |feature| | ||
class_name = File.basename(feature).match(/(.*)\.feature$/)[1] + "_Test" | ||
write_file("src/test/java/cucumber/test/#{class_name}.java", <<-EOF) | ||
package cucumber.test; | ||
import cucumber.junit.Cucumber; | ||
import cucumber.junit.Feature; | ||
import org.junit.runner.RunWith; | ||
@RunWith(Cucumber.class) | ||
@Feature("#{feature}") | ||
public class #{class_name} {} | ||
EOF | ||
end | ||
end | ||
|
||
def assert_passing_scenario | ||
2 tests because we have 2 steps | ||
assert_partial_output("Tests run: 2, Failures: 0, Errors: 0, Skipped: 0", all_output) | ||
assert_success true | ||
end | ||
end | ||
|
||
World(CucumberJavaMappings) | ||
|
||
Before do | ||
@aruba_timeout_seconds = 10 | ||
end |
7 changes: 5 additions & 2 deletions
7
...cumber/runtime/junit/cucumber_runner.java → ...r/runtime/junit/cucumber_runner_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
package cucumber.runtime.junit; | ||
|
||
import cucumber.junit.Cucumber; | ||
import cucumber.junit.Feature; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* In order to run a Cucumber Feature from JUnit - all you need is an empty class annotated like below. | ||
* The class must be named the same as the feature file and be in the same package. | ||
* The @Feature annotation is not required if the test class is named the same as the feature file and | ||
* in the same package. | ||
* | ||
* You can write this stub class by hand, but Cucumber will also have a tool that can generate them | ||
* from .feature sources. | ||
*/ | ||
@RunWith(Cucumber.class) | ||
public class cucumber_runner {} | ||
@Feature("cucumber_runner.feature") | ||
public class cucumber_runner_Test {} |
File renamed without changes.