Skip to content

Commit

Permalink
Added built-in support for enum conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Oct 13, 2012
1 parent 8b8a897 commit e5f35d1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<artifactId>thucydides</artifactId>
<groupId>net.thucydides</groupId>
<version>0.9.24</version>
<version>0.9.28</version>
</parent>
<groupId>net.thucydides</groupId>
<artifactId>thucydides-jbehave-plugin</artifactId>
<version>0.9.24-SNAPSHOT</version>
<version>0.9.28-SNAPSHOT</version>
<name>thucydides-jbehave-plugin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/thucydides/jbehave/ThucydidesJBehave.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jbehave.core.reporters.FilePrintStreamFactory;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.ParameterConverters;

import java.util.List;
import java.util.Properties;
Expand Down Expand Up @@ -41,6 +42,9 @@ public static Configuration defaultConfiguration(net.thucydides.core.webdriver.C
viewResources.put("decorateNonHtml", "true");

return new ParanamerConfiguration()
.useParameterConverters(
new ParameterConverters().addConverters(new ParameterConverters.EnumConverter(),
new ParameterConverters.EnumListConverter()))
.useStoryReporterBuilder(
new StoryReporterBuilder()
.withDefaultFormats()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package net.thucydides.jbehave;

public class APassingBehaviorWithState extends ThucydidesJUnitStory {
public APassingBehaviorWithState() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@

public class SomeStepsWithState {

String field;
public enum Color {
RED, BLUE, GREEN
}

Color field;

@Given("I have a field")
public void setupField() {
}

@When("I instantiate that field with value $value")
public void instantiateFieldWith(String value) {
public void instantiateFieldWith(Color value) {
this.field = value;

}

@Then("the field should be set to $value in the following steps")
public void checkValueIsSet(String value) {
public void checkValueIsSet(Color value) {
assertThat(field, is(value));
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/stories/aPassingBehaviorWithState.story
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Scenario: A scenario that uses state

Given I have a field
When I instantiate that field with value Red
Then the field should be set to Red in the following steps
When I instantiate that field with value RED
Then the field should be set to RED in the following steps

0 comments on commit e5f35d1

Please sign in to comment.