diff --git a/src/main/java/org/nexial/core/model/IterationManager.java b/src/main/java/org/nexial/core/model/IterationManager.java index b6fea426..5bb20729 100644 --- a/src/main/java/org/nexial/core/model/IterationManager.java +++ b/src/main/java/org/nexial/core/model/IterationManager.java @@ -93,6 +93,7 @@ public static IterationManager newInstance(String iteration) { instance.last = 1; instance.lowest = 1; instance.highest = 1; + instance.iterations.clear(); return instance; } @@ -118,7 +119,7 @@ public static IterationManager newInstance(String iteration) { * The difference will be resolved internally within this method. */ public boolean skip(int iterationIndex) { - return !iterations.isEmpty() && !iterations.contains(iterationIndex + 1); + return iterations.isEmpty() || !iterations.contains(iterationIndex + 1); } public int getLowestIteration() { return lowest; } diff --git a/src/test/java/org/nexial/core/model/IterationManagerTest.java b/src/test/java/org/nexial/core/model/IterationManagerTest.java index 4ce53d08..fd55ebd4 100644 --- a/src/test/java/org/nexial/core/model/IterationManagerTest.java +++ b/src/test/java/org/nexial/core/model/IterationManagerTest.java @@ -48,8 +48,6 @@ public void testSimpleCases() { assertEquals(subject.getLowestIteration(), 1); assertEquals(subject.getHighestIteration(), 1); assertEquals(subject.getIterationCount(), 1); - assertFalse(subject.skip(0)); - for (int i = 1; i < 200; i++) { assertTrue(subject.skip(i)); } subject = IterationManager.newInstance("1,2,3,4,5"); assertEquals(subject.getFirstIteration(), 1); @@ -115,21 +113,10 @@ public void testComplexCases() { subject = IterationManager.newInstance("1-5,1 - 5, 001 - 05.00"); assertEquals(subject.getFirstIteration(), 1); - assertEquals(subject.getLastIteration(), 5); + assertEquals(subject.getLastIteration(), 1); assertEquals(subject.getLowestIteration(), 1); - assertEquals(subject.getHighestIteration(), 5); - assertEquals(subject.getIterationCount(), 10); - for (int i = 1; i < 200; i++) { - if (i == 0 || - i == 1 || - i == 2 || - i == 3 || - i == 4) { - assertFalse(subject.skip(i)); - } else { - assertTrue(subject.skip(i)); - } - } + assertEquals(subject.getHighestIteration(), 1); + assertEquals(subject.getIterationCount(), 1); }