citrusframework / citrusframework/citrus
async container does not fail due to false assertions
- Dominant language
- Java
- Stars
- 485
- Forks
- 155
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 6
Description
Memo to myself:
The asserts in the `AbstractTestAction` will not cause the test to fail even if they evaluate to false. To fix this, I had to add a catch of `AssertionError` and rethrow it as a `CitrusRuntimeException`.
```java
@CitrusTest
public void testUpdateCountHandlingOnExecute() {
async().actions(new AbstractTestAction() {
@Override
public void doExecute(final TestContext context) {
try {
final Connection connection = jdbcDriver.connect(serverUrl, new Properties());
Assert.assertNotNull(connection);
try(final Statement statement = connection.createStatement()){
final boolean isResultSet = statement.execute(SAMPLE_UPDATE_SQL);
assertFalse(isResultSet);
assertEquals(ROWS_UPDATED, statement.getUpdateCount());
}
} catch (final SQLException | AssertionError e) {
throw new CitrusRuntimeException(e);
}
}
}
);
receive(jdbcServer)
.message(JdbcMessage.execute(SAMPLE_UPDATE_SQL));
send(jdbcServer)
.message(JdbcMessage.success().rowsUpdated(ROWS_UPDATED));
}
```
Contributor guide
Research direction
Start by tracing the async container's handling of the AbstractTestAction shown in testUpdateCountHandlingOnExecute. Reproduce the case with the JDBC update-count test and verify that a false assertion propagates as a test failure without manually catching AssertionError and wrapping it in CitrusRuntimeException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100