Title: [1104] trunk/core/jbehave-core/src/java/org/jbehave/scenario: Better formatting of stepdoc report, which now includes methods by default.

Diff

Modified: trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepdocGeneratorBehaviour.java (1103 => 1104)

--- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepdocGeneratorBehaviour.java	2009-02-22 13:42:43 UTC (rev 1103)
+++ trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/steps/StepdocGeneratorBehaviour.java	2009-02-22 13:54:27 UTC (rev 1104)
@@ -12,7 +12,7 @@
 	
     @Test
     public void shouldGenerateStepdocsInPriorityOrder() {
-        StepdocGenerator generator = new DefaultStepdoc2Generator();
+        StepdocGenerator generator = new DefaultStepdocGenerator();
         MySteps steps = new MySteps();
         List<Stepdoc> stepdocs = generator.generate(steps.getClass());
         ensureThat(stepdocs.get(0).getPattern(), equalTo("a given"));

Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/Configuration.java (1103 => 1104)

--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/Configuration.java	2009-02-22 13:42:43 UTC (rev 1103)
+++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/Configuration.java	2009-02-22 13:54:27 UTC (rev 1104)
@@ -22,6 +22,7 @@
  * is provided.
  * 
  * @author Elizabeth Keogh
+ * @author Mauro Talevi
  */
 public interface Configuration {
 

Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/MostUsefulConfiguration.java (1103 => 1104)

--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/MostUsefulConfiguration.java	2009-02-22 13:42:43 UTC (rev 1103)
+++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/MostUsefulConfiguration.java	2009-02-22 13:54:27 UTC (rev 1104)
@@ -12,7 +12,7 @@
 import org.jbehave.scenario.reporters.PrintStreamStepdocReporter;
 import org.jbehave.scenario.reporters.ScenarioReporter;
 import org.jbehave.scenario.reporters.StepdocReporter;
-import org.jbehave.scenario.steps.DefaultStepdoc2Generator;
+import org.jbehave.scenario.steps.DefaultStepdocGenerator;
 import org.jbehave.scenario.steps.StepCreator;
 import org.jbehave.scenario.steps.StepdocGenerator;
 import org.jbehave.scenario.steps.UnmatchedToPendingStepCreator;
@@ -86,12 +86,18 @@
         return new ScenarioGivenWhenThenAnd();
     }
 
+    /**
+     * Generates stepdocs
+     */
 	public StepdocGenerator forGeneratingStepdoc() {
-		return new DefaultStepdoc2Generator();
+		return new DefaultStepdocGenerator();
 	}
 
+	 /**
+     * Reports stepdocs to System.out
+     */
 	public StepdocReporter forReportingStepdoc() {
-		return new PrintStreamStepdocReporter();
+		return new PrintStreamStepdocReporter(true);
 	}
 
 }

Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamStepdocReporter.java (1103 => 1104)

--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamStepdocReporter.java	2009-02-22 13:42:43 UTC (rev 1103)
+++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamStepdocReporter.java	2009-02-22 13:54:27 UTC (rev 1104)
@@ -1,5 +1,7 @@
 package org.jbehave.scenario.reporters;
 
+import static java.text.MessageFormat.format;
+
 import java.io.PrintStream;
 import java.util.List;
 
@@ -12,6 +14,9 @@
  */
 public class PrintStreamStepdocReporter implements StepdocReporter {
 
+	private static final String STEP = "Step: {0} {1}";
+	private static final String ALIASES = "Aliases: {0}";
+	private static final String METHOD = "Method: {0}";
 	private final PrintStream output;
 	private final boolean reportMethods;
 
@@ -19,6 +24,10 @@
 		this(System.out);
 	}
 
+	public PrintStreamStepdocReporter(boolean reportMethods) {
+		this(System.out, reportMethods);
+	}
+
 	public PrintStreamStepdocReporter(PrintStream output) {
 		this(output, false);
 	}
@@ -30,13 +39,12 @@
 
 	public void report(List<Stepdoc> stepdocs) {
 		for (Stepdoc stepdoc : stepdocs) {
-			output.println(stepdoc.getAnnotation().getSimpleName() + " "
-					+ stepdoc.getPattern());
+			output.println(format(STEP, stepdoc.getAnnotation().getSimpleName(), stepdoc.getPattern()));
 			if (stepdoc.getAliasPatterns().size() > 0) {
-				output.println("Aliases: " + stepdoc.getAliasPatterns());
+				output.println(format(ALIASES, stepdoc.getAliasPatterns()));
 			}
 			if (reportMethods) {
-				output.println("Method: " + stepdoc.getMethod());
+				output.println(format(METHOD, stepdoc.getMethod()));
 			}
 		}
 	}

Deleted: trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/DefaultStepdoc2Generator.java (1103 => 1104)

--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/DefaultStepdoc2Generator.java	2009-02-22 13:42:43 UTC (rev 1103)
+++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/DefaultStepdoc2Generator.java	2009-02-22 13:54:27 UTC (rev 1104)
@@ -1,42 +0,0 @@
-package org.jbehave.scenario.steps;
-
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jbehave.scenario.annotations.Aliases;
-import org.jbehave.scenario.annotations.Given;
-import org.jbehave.scenario.annotations.Then;
-import org.jbehave.scenario.annotations.When;
-
-public class DefaultStepdoc2Generator implements StepdocGenerator {
-
-	public List<Stepdoc> generate(Class<?> stepsClass) {
-		List<Stepdoc> stepdocs = new LinkedList<Stepdoc>();
-		for (Method method : stepsClass.getMethods()) {
-			if (method.isAnnotationPresent(Given.class)) {
-				stepdocs.add(new Stepdoc(Given.class, method.getAnnotation(Given.class).value(), 
-						aliases(method), method));
-			}
-			if (method.isAnnotationPresent(When.class)) {
-				stepdocs.add(new Stepdoc(When.class, method.getAnnotation(When.class).value(), 
-						aliases(method), method));
-			}
-			if (method.isAnnotationPresent(Then.class)) {
-				stepdocs.add(new Stepdoc(Then.class, method.getAnnotation(Then.class).value(), 
-						aliases(method), method));
-			}
-		}
-		Collections.sort(stepdocs);
-		return stepdocs;		
-	}
-
-	private String[] aliases(Method method) {
-		if (method.isAnnotationPresent(Aliases.class)) {
-			return method.getAnnotation(Aliases.class).values();
-		}
-		return new String[]{};
-	}
-
-}

Copied: trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/DefaultStepdocGenerator.java (from rev 1103, trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/DefaultStepdoc2Generator.java) (0 => 1104)

--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/DefaultStepdocGenerator.java	                        (rev 0)
+++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/DefaultStepdocGenerator.java	2009-02-22 13:54:27 UTC (rev 1104)
@@ -0,0 +1,42 @@
+package org.jbehave.scenario.steps;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jbehave.scenario.annotations.Aliases;
+import org.jbehave.scenario.annotations.Given;
+import org.jbehave.scenario.annotations.Then;
+import org.jbehave.scenario.annotations.When;
+
+public class DefaultStepdocGenerator implements StepdocGenerator {
+
+	public List<Stepdoc> generate(Class<?> stepsClass) {
+		List<Stepdoc> stepdocs = new LinkedList<Stepdoc>();
+		for (Method method : stepsClass.getMethods()) {
+			if (method.isAnnotationPresent(Given.class)) {
+				stepdocs.add(new Stepdoc(Given.class, method.getAnnotation(Given.class).value(), 
+						aliases(method), method));
+			}
+			if (method.isAnnotationPresent(When.class)) {
+				stepdocs.add(new Stepdoc(When.class, method.getAnnotation(When.class).value(), 
+						aliases(method), method));
+			}
+			if (method.isAnnotationPresent(Then.class)) {
+				stepdocs.add(new Stepdoc(Then.class, method.getAnnotation(Then.class).value(), 
+						aliases(method), method));
+			}
+		}
+		Collections.sort(stepdocs);
+		return stepdocs;		
+	}
+
+	private String[] aliases(Method method) {
+		if (method.isAnnotationPresent(Aliases.class)) {
+			return method.getAnnotation(Aliases.class).values();
+		}
+		return new String[]{};
+	}
+
+}


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to