Skip to content

Commit 8104d50

Browse files
committed
Improve fail message when server is still running
Makes it easier to find out why the test fails. The developer now sees a message like SFTP server is still running on port 12345. instead of Expecting code to raise a throwable.
1 parent 6b1a526 commit 8104d50

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</parent>
1010

1111
<artifactId>fake-sftp-server-rule</artifactId>
12-
<version>2.0.0-SNAPSHOT</version>
12+
<version>1.1.1-SNAPSHOT</version>
1313
<packaging>jar</packaging>
1414

1515
<name>Fake SFTP Server Rule</name>

src/test/java/com/github/stefanbirkner/fakesftpserver/rule/FakeSftpServerRuleTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.apache.commons.io.IOUtils.toByteArray;
2424
import static org.assertj.core.api.Assertions.assertThat;
2525
import static org.assertj.core.api.Assertions.assertThatThrownBy;
26+
import static org.assertj.core.api.Assertions.catchThrowable;
2627

2728
/* Wording according to the draft:
2829
* http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13
@@ -591,7 +592,14 @@ public void after_an_erroneous_test_SFTP_server_is_shutdown() {
591592
private void assertConnectionToSftpServerNotPossible(
592593
FakeSftpServerRule sftpServer
593594
) {
594-
assertThatThrownBy(() -> connectToServer(sftpServer))
595+
Throwable throwable = catchThrowable(
596+
() -> connectToServer(sftpServer)
597+
);
598+
assertThat(throwable)
599+
.withFailMessage(
600+
"SFTP server is still running on port %d.",
601+
sftpServer.getPort()
602+
)
595603
.hasCauseInstanceOf(ConnectException.class);
596604
}
597605
}

0 commit comments

Comments
 (0)