Skip to content

Commit 391e4fe

Browse files
Fixed Ignore exception issue whereby it was still executing every sta… (#1538)
* Fixed Ignore exception issue whereby it was still executing every statement in the script table even though it will ignore the result * added some tests to cover the fixed scenario and more details in the release notes * added a line to existing ignore tests to show both ignore script tests and ignore all tests exceptions working --------- Co-authored-by: mcguinness <[email protected]>
1 parent cfede4f commit 391e4fe

File tree

5 files changed

+48
-15
lines changed

5 files changed

+48
-15
lines changed

Diff for: FitNesseRoot/FitNesse/ReleaseNotes/content.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Support using Java 17 and 21, 11 remains supported too ([[1525][https://github.com/unclebob/fitnesse/pull/1525]])
88
* IMPORTANT: !style_code[System.exit()] is no longer prevented by default ([[1524][https://github.com/unclebob/fitnesse/pull/1524]]).
99
* Fix SLF4J logging ([[1522][https://github.com/unclebob/fitnesse/pull/1522]])
10+
* Fix IgnoreAllTests exception and IgnoreScriptTest exception issue whereby if either exception is thrown it would still execute subsequent statements in the script table
1011

1112
!2 20240707
1213
* Allow usage of JDK > 18 ([[1513][https://github.com/unclebob/fitnesse/pull/1513]]).

Diff for: src/fitnesse/slim/StatementExecutor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private void checkForPatternOfFixturesHandlingSymbols(String symbolName){
191191

192192

193193
private void checkExceptionForStop(Throwable exception) {
194-
if (isStopTestException(exception) || isStopSuiteException(exception)) {
194+
if (isStopTestException(exception) || isStopSuiteException(exception) || isIgnoreAllTestsException(exception) || isIgnoreScriptTestException(exception)) {
195195
stopRequested = true;
196196
}
197197
}

Diff for: src/fitnesse/slim/test/TestSlim.java

+22-11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// Released under the terms of the CPL Common Public License version 1.0.
33
package fitnesse.slim.test;
44

5+
import fitnesse.slim.SlimIgnoreAllTestsException;
6+
import fitnesse.slim.SlimIgnoreScriptTestException;
7+
58
import java.util.Arrays;
69
import java.util.Date;
710
import java.util.List;
@@ -38,7 +41,7 @@ public TestSlim(int constructorArg, TestSlim other) {
3841
this.constructorArg = constructorArg;
3942
stringArg = other.getStringArg();
4043
}
41-
44+
4245
public TestSlim createTestSlimWithString(String string) {
4346
TestSlim testSlim = new TestSlim();
4447
testSlim.setString(string);
@@ -49,7 +52,7 @@ public TestSlim createTestSlimWithString(String string) {
4952
public String toString() {
5053
return "TestSlim: " + constructorArg + ", " + stringArg;
5154
}
52-
55+
5356
public void nilad() {
5457
niladWasCalled = true;
5558
}
@@ -113,7 +116,7 @@ public String getStringArg() {
113116
public Date getDateArg() {
114117
return new Date(dateArg.getTime());
115118
}
116-
119+
117120
public void oneInt(int arg) {
118121
intArg = arg;
119122
}
@@ -236,11 +239,11 @@ public String nullString() {
236239
public boolean isSame(Object other) {
237240
return this == other;
238241
}
239-
242+
240243
public String getStringFromOther(TestSlim other) {
241244
return other.getStringArg();
242245
}
243-
246+
244247
public Zork oneZork(Zork zork) {
245248
this.zork = zork;
246249
return zork;
@@ -253,22 +256,30 @@ public Zork getZork() {
253256

254257
class NoSuchConverter {
255258
}
256-
259+
257260
public boolean throwNormal() throws Exception {
258261
throw new Exception("This is my exception");
259262
}
260-
263+
261264
public boolean throwStopping() throws Exception {
262265
throw new StopTestException("This is a stop test exception");
263266
}
264-
267+
268+
public boolean throwIgnoreAllStopping() throws Exception {
269+
throw new SlimIgnoreAllTestsException("This is an ignore all script test exception");
270+
}
271+
272+
public boolean throwIgnoreScriptStopping() throws Exception {
273+
throw new SlimIgnoreScriptTestException("This is an ignore script test exception");
274+
}
275+
265276
public boolean throwExceptionWithMessage() throws Exception {
266277
throw new Exception("message:<<Test message>>");
267278
}
268-
279+
269280
public boolean throwStopTestExceptionWithMessage() throws Exception {
270281
throw new StopTestException("message:<<Stop Test>>");
271-
}
282+
}
272283

273284
public String concatenateThreeArgs(String first, String second, String third) {
274285
return first + " " + second + " " + third;
@@ -281,7 +292,7 @@ public void setMap(Map<String, String> map) {
281292
public Map<String, String> getMap() {
282293
return map;
283294
}
284-
295+
285296
@SuppressWarnings("serial")
286297
class StopTestException extends Exception {
287298
public StopTestException(String description) {

Diff for: test/fitnesse/slim/SlimServiceTestBase.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,26 @@ public void stopTestExceptionThrown() throws Exception {
243243
assertNull(results.get("id2"));
244244
}
245245

246+
@Test
247+
public void IgnoreAllTestExceptionThrownAndNextStatementResultIsNull() throws Exception {
248+
addImportAndMake();
249+
statements.add(new CallInstruction("id", "testSlim", "throwIgnoreAllStopping"));
250+
statements.add(new CallInstruction("id2", "testSlim", "echoString", new Object[] { "hello" }));
251+
Map<String, Object> results = slimClient.invokeAndGetResponse(statements);
252+
assertContainsException("__EXCEPTION__:IGNORE_ALL_TESTS:", "id", results);
253+
assertNull(results.get("id2"));
254+
}
255+
256+
@Test
257+
public void IgnoreScriptTestExceptionThrownAndNextStatementResultIsNull() throws Exception {
258+
addImportAndMake();
259+
statements.add(new CallInstruction("id", "testSlim", "throwIgnoreScriptStopping"));
260+
statements.add(new CallInstruction("id2", "testSlim", "echoString", new Object[] { "hello" }));
261+
Map<String, Object> results = slimClient.invokeAndGetResponse(statements);
262+
assertContainsException("__EXCEPTION__:IGNORE_SCRIPT_TEST:", "id", results);
263+
assertNull(results.get("id2"));
264+
}
265+
246266
@Test
247267
public void canSpecifyAnInteractionClass() {
248268
final SlimService.Options options = SlimService.parseCommandLine(new String[]{"-i", "fitnesse.slim.fixtureInteraction.DefaultInteraction"});
@@ -273,5 +293,4 @@ public void canSpecifyComplexArgs() {
273293
assertTrue("should be verbose", options.verbose);
274294
assertEquals("should have set port", 7890, options.port);
275295
}
276-
277296
}

Diff for: test/fitnesse/testsystems/slim/SlimTestSystemTableProcessingTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,19 @@ public void tableFollowingIgnoreScriptTestExceptionExecuted() throws TestExecuti
5959
String exceptionId = SlimServer.EXCEPTION_IGNORE_SCRIPT_TEST_TAG + "table1 with random ignore exception";
6060
slimTestSystem.processTable(table(exceptionId), false);
6161
slimTestSystem.processTable(table("Table2"), false);
62+
slimTestSystem.processTable(table("Table3"), false);
6263

63-
assertTestRecords(ignore(exceptionId), pass("Table2"));
64+
assertTestRecords(ignore(exceptionId), pass("Table2"), pass("Table3"));
6465
}
6566

6667
@Test
6768
public void tableFollowingIgnoreAllTestsExceptionIgnored() throws TestExecutionException {
6869
String exceptionId = SlimServer.EXCEPTION_IGNORE_ALL_TESTS_TAG + "table1 with random ignore exception";
6970
slimTestSystem.processTable(table(exceptionId), false);
7071
slimTestSystem.processTable(table("Table2"), false);
72+
slimTestSystem.processTable(table("Table3"), false);
7173

72-
assertTestRecords(ignore(exceptionId), ignore("Table2"));
74+
assertTestRecords(ignore(exceptionId), ignore("Table2"), ignore("Table3"));
7375
}
7476

7577
@Test

0 commit comments

Comments
 (0)