Skip to content

Commit

Permalink
added some tests to cover the fixed scenario and more details in the …
Browse files Browse the repository at this point in the history
…release notes
  • Loading branch information
sunshineMcg committed Oct 29, 2024
1 parent 974d98c commit 081ea03
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion FitNesseRoot/FitNesse/ReleaseNotes/content.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
!2 Pending Changes
* Fix SLF4J logging ([[1522][https://github.com/unclebob/fitnesse/pull/1522]])
* Fix Ignore exception issue whereby it still executes every statement in the script table even though it will ignore the result
* 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
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);
}

}

0 comments on commit 081ea03

Please sign in to comment.