Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Ignore exception issue whereby it was still executing every sta… #1538

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions FitNesseRoot/FitNesse/ReleaseNotes/content.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
!2 Pending Changes
* Fix SLF4J logging ([[1522][https://github.com/unclebob/fitnesse/pull/1522]])
* Fix IgnoreAllTests exception and IgnoreScriptTest exception issue whereby if either exception is thrown it would still execute subsequent statements in the script table

!2 20240707
* Allow usage of JDK > 18 ([[1513][https://github.com/unclebob/fitnesse/pull/1513]]).
Expand Down
2 changes: 1 addition & 1 deletion src/fitnesse/slim/StatementExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void checkForPatternOfFixturesHandlingSymbols(String symbolName){


private void checkExceptionForStop(Throwable exception) {
if (isStopTestException(exception) || isStopSuiteException(exception)) {
if (isStopTestException(exception) || isStopSuiteException(exception) || isIgnoreAllTestsException(exception) || isIgnoreScriptTestException(exception)) {
stopRequested = true;
}
}
Expand Down
33 changes: 22 additions & 11 deletions src/fitnesse/slim/test/TestSlim.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// Released under the terms of the CPL Common Public License version 1.0.
package fitnesse.slim.test;

import fitnesse.slim.SlimIgnoreAllTestsException;
import fitnesse.slim.SlimIgnoreScriptTestException;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -38,7 +41,7 @@ public TestSlim(int constructorArg, TestSlim other) {
this.constructorArg = constructorArg;
stringArg = other.getStringArg();
}

public TestSlim createTestSlimWithString(String string) {
TestSlim testSlim = new TestSlim();
testSlim.setString(string);
Expand All @@ -49,7 +52,7 @@ public TestSlim createTestSlimWithString(String string) {
public String toString() {
return "TestSlim: " + constructorArg + ", " + stringArg;
}

public void nilad() {
niladWasCalled = true;
}
Expand Down Expand Up @@ -113,7 +116,7 @@ public String getStringArg() {
public Date getDateArg() {
return new Date(dateArg.getTime());
}

public void oneInt(int arg) {
intArg = arg;
}
Expand Down Expand Up @@ -236,11 +239,11 @@ public String nullString() {
public boolean isSame(Object other) {
return this == other;
}

public String getStringFromOther(TestSlim other) {
return other.getStringArg();
}

public Zork oneZork(Zork zork) {
this.zork = zork;
return zork;
Expand All @@ -253,22 +256,30 @@ public Zork getZork() {

class NoSuchConverter {
}

public boolean throwNormal() throws Exception {
throw new Exception("This is my exception");
}

public boolean throwStopping() throws Exception {
throw new StopTestException("This is a stop test exception");
}


public boolean throwIgnoreAllStopping() throws Exception {
throw new SlimIgnoreAllTestsException("This is an ignore all script test exception");
}

public boolean throwIgnoreScriptStopping() throws Exception {
throw new SlimIgnoreScriptTestException("This is an ignore script test exception");
}

public boolean throwExceptionWithMessage() throws Exception {
throw new Exception("message:<<Test message>>");
}

public boolean throwStopTestExceptionWithMessage() throws Exception {
throw new StopTestException("message:<<Stop Test>>");
}
}

public String concatenateThreeArgs(String first, String second, String third) {
return first + " " + second + " " + third;
Expand All @@ -281,7 +292,7 @@ public void setMap(Map<String, String> map) {
public Map<String, String> getMap() {
return map;
}

@SuppressWarnings("serial")
class StopTestException extends Exception {
public StopTestException(String description) {
Expand Down
21 changes: 20 additions & 1 deletion test/fitnesse/slim/SlimServiceTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,26 @@ public void stopTestExceptionThrown() throws Exception {
assertNull(results.get("id2"));
}

@Test
public void IgnoreAllTestExceptionThrownAndNextStatementResultIsNull() throws Exception {
addImportAndMake();
statements.add(new CallInstruction("id", "testSlim", "throwIgnoreAllStopping"));
statements.add(new CallInstruction("id2", "testSlim", "echoString", new Object[] { "hello" }));
Map<String, Object> results = slimClient.invokeAndGetResponse(statements);
assertContainsException("__EXCEPTION__:IGNORE_ALL_TESTS:", "id", results);
assertNull(results.get("id2"));
}

@Test
public void IgnoreScriptTestExceptionThrownAndNextStatementResultIsNull() throws Exception {
addImportAndMake();
statements.add(new CallInstruction("id", "testSlim", "throwIgnoreScriptStopping"));
statements.add(new CallInstruction("id2", "testSlim", "echoString", new Object[] { "hello" }));
Map<String, Object> results = slimClient.invokeAndGetResponse(statements);
assertContainsException("__EXCEPTION__:IGNORE_SCRIPT_TEST:", "id", results);
assertNull(results.get("id2"));
}

@Test
public void canSpecifyAnInteractionClass() {
final SlimService.Options options = SlimService.parseCommandLine(new String[]{"-i", "fitnesse.slim.fixtureInteraction.DefaultInteraction"});
Expand Down Expand Up @@ -273,5 +293,4 @@ public void canSpecifyComplexArgs() {
assertTrue("should be verbose", options.verbose);
assertEquals("should have set port", 7890, options.port);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,19 @@ public void tableFollowingIgnoreScriptTestExceptionExecuted() throws TestExecuti
String exceptionId = SlimServer.EXCEPTION_IGNORE_SCRIPT_TEST_TAG + "table1 with random ignore exception";
slimTestSystem.processTable(table(exceptionId), false);
slimTestSystem.processTable(table("Table2"), false);
slimTestSystem.processTable(table("Table3"), false);

assertTestRecords(ignore(exceptionId), pass("Table2"));
assertTestRecords(ignore(exceptionId), pass("Table2"), pass("Table3"));
}

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

assertTestRecords(ignore(exceptionId), ignore("Table2"));
assertTestRecords(ignore(exceptionId), ignore("Table2"), ignore("Table3"));
}

@Test
Expand Down