citrusframework / citrusframework/citrus

Failed assertions in async containers do not fail the test (Citrus 3)

Open
#800 5 comments 0 reactions 0 assignees View on GitHub
question to-discuss
Dominant language
Java
Stars
485
Forks
155
Avg merge
4d 22h
Merged PRs (30d)
6

Description

**Citrus Version**
3.0.0

**Expected behavior**
When a validation within an async container fails, I expect the whole test to fail.

**Actual behavior**
I can see the failures in the log, however, the main thread doesn't seem to be bothered with the failures and completes successfully.

**Test case sample**
```
@Test
@CitrusTest
public void test() {
run(async().actions(
applyBehavior(new ServerMockBehavior())
));
// Execute a function in a bean I'm testing (calls the mocked server via RestTemplate)
myBean.execute(execution);
}
---
public class ServerMockBehavior implements TestBehavior {
@Override
public void apply(TestActionRunner r) {
r.run(http().server("myService")
.receive().post().path("/some/path").message().type(MessageType.JSON)
.body(new ClassPathResource("data/request.json"))
);
r.run(http().server("myService")
.send().response().message().status(HttpStatus.NO_CONTENT)
);
}
}
```

**Workaround for the sample above**
I'm currently just catching the validation exceptions in the receive-Action and let my mocked servers respond with a 500 error, so the application in the main thread fails.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.