commit d562fa92f3c9766b07f18d4d9aef84ad54ff1bec
Author:     Alex Lehmann <alexl...@gmail.com>
AuthorDate: Fri Mar 16 00:17:14 2012 +0100
Commit:     Alex Lehmann <alexl...@gmail.com>
CommitDate: Fri Mar 16 00:17:14 2012 +0100

    JBEHAVE-744: Unit test 
CompositeStepCandidateBehaviour.shouldMatchCompositeStepsAndCreateComposedNestedSteps
 can fail due to random list ordering
    added lookup for base step

diff --git 
a/jbehave-core/src/test/java/org/jbehave/core/steps/CompositeStepCandidateBehaviour.java
 
b/jbehave-core/src/test/java/org/jbehave/core/steps/CompositeStepCandidateBehaviour.java
index 5e00bc5..d1e98bf 100755
--- 
a/jbehave-core/src/test/java/org/jbehave/core/steps/CompositeStepCandidateBehaviour.java
+++ 
b/jbehave-core/src/test/java/org/jbehave/core/steps/CompositeStepCandidateBehaviour.java
@@ -17,6 +17,7 @@ import java.util.Map;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertNotNull;
 
 public class CompositeStepCandidateBehaviour {
 
@@ -151,7 +152,15 @@ public class CompositeStepCandidateBehaviour {
     public void shouldMatchCompositeStepsAndCreateComposedNestedSteps() {
         CompositeNestedSteps steps = new CompositeNestedSteps();
         List<StepCandidate> candidates = steps.listCandidates();
-        StepCandidate candidate = candidates.get(0);
+        // find main step
+        StepCandidate candidate = null;
+        for(StepCandidate cand: candidates) {
+            if(cand.getPatternAsString().equals("all buttons are enabled")) {
+                candidate = cand;
+                break;
+            }
+        }
+        assertNotNull(candidate);
         assertThat(candidate.isComposite(), is(true));
         Map<String, String> noNamedParameters = new HashMap<String, String>();
         List<Step> composedSteps = new ArrayList<Step>();



Reply via email to