Skip to content

Commit

Permalink
SINT: Assert something when succeeding
Browse files Browse the repository at this point in the history
It is good practice to require an explicit assertion for a test to
fail, but also for one to succeed. Although the test silently
succeeds when it does not fail, making this explicit describes
intent better.

This commit adds an explicit assertion to all tests in

- GeolocationIntegrationTest
- MoodIntegrationTest
- UserTuneIntegrationTest
  • Loading branch information
guusdk committed Nov 4, 2021
1 parent 2cb1753 commit 59c1df4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ public void testNotification() throws Exception {

// Wait for the data to be received.
try {
geoLocationReceived.waitForResult(timeout);
Object result = geoLocationReceived.waitForResult(timeout);

// Explicitly assert the success case.
Assertions.assertNotNull(result, "Expected to receive a PEP notification, but did not.");
} catch (TimeoutException e) {
Assertions.fail("Expected to receive a PEP notification, but did not.");
}
Expand Down Expand Up @@ -165,7 +168,10 @@ public void testNotificationAfterFilterChange() throws Exception {

// Wait for the data to be received.
try {
geoLocationReceived.waitForResult(timeout);
Object result = geoLocationReceived.waitForResult(timeout);

// Explicitly assert the success case.
Assertions.assertNotNull(result, "Expected to receive a PEP notification, but did not.");
} catch (TimeoutException e) {
Assertions.fail("Expected to receive a PEP notification, but did not.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ public void testNotificationAfterFilterChange() throws Exception {

// Wait for the data to be received.
try {
moodReceived.waitForResult(timeout);
Object result = moodReceived.waitForResult(timeout);

// Explicitly assert the success case.
Assertions.assertNotNull(result, "Expected to receive a PEP notification, but did not.");
} catch (TimeoutException e) {
Assertions.fail("Expected to receive a PEP notification, but did not.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ public void testNotification() throws Exception {

// Wait for the data to be received.
try {
userTuneReceived.waitForResult(timeout);
Object result = userTuneReceived.waitForResult(timeout);

// Explicitly assert the success case.
Assertions.assertNotNull(result, "Expected to receive a PEP notification, but did not.");
} catch (TimeoutException e) {
Assertions.fail("Expected to receive a PEP notification, but did not.");
}
Expand Down Expand Up @@ -136,7 +139,10 @@ public void testNotificationAfterFilterChange() throws Exception {

// Wait for the data to be received.
try {
userTuneReceived.waitForResult(timeout);
Object result = userTuneReceived.waitForResult(timeout);

// Explicitly assert the success case.
Assertions.assertNotNull(result, "Expected to receive a PEP notification, but did not.");
} catch (TimeoutException e) {
Assertions.fail("Expected to receive a PEP notification, but did not.");
}
Expand Down

0 comments on commit 59c1df4

Please sign in to comment.